-
Notifications
You must be signed in to change notification settings - Fork 131
Specify value for custom fields on the File type when uploading files #55
Comments
Comment by marktani You can specify the file name when using form.append('data', body, {
filename: fileName
}) currently, addititional fields on the file node need to be updated after the file has been uploaded using mutation {
updateFile(
id: "some-id"
category: "my category"
) {
id
}
} |
Comment by sedubois Thanks. But if I need to change after upload, I can as well just change in the data browser. It would just be great to avoid the extra step. Also about specifying the filename, is there any way to do that using |
Comment by marktani This uploads your local file curl -X POST 'https://api.graph.cool/file/v1/__PROJECT_ID__' -F "data=@example.png;filename=myname.png" I updated the line in the docs to reflect this :) |
Comment by sedubois Thanks @marktani that's helpful 🙂 Would also be nice to specify custom fields that way:
If the field has another type than String (e.g numeric), it could be parsed the same way as is done in the console when typing values with the keyboard there. |
Comment by kbrandwijk +1 for file upload with additional metadata in a single request. |
Comment by patoncrispy I would also love to see something like this. Adding other metadata to the body of the request shouldn't be too tricky, right? |
Comment by kbrandwijk Please checkout my metadata-file-proxy example: https://github.com/kbrandwijk/functions/tree/file-proxy/file-proxy for a workaround until we get out of box support for this in the Graphcool File API. You can strip out some functionality if you just need the upload with metadata. |
Comment by lucfranken Agree this is important. It will otherwise also leave a chance that you get stuck with invalid data like orphan uploads where the mutation afterwards did not succeed. |
Issue by sedubois
Monday Apr 17, 2017 at 13:08 GMT
Originally opened as https://github.com/graphcool/prisma/issues/174
Currently I know of these two ways to upload files:
But in both cases, AFAIK there's no way to assign at the same time some extra data (e.g I added a
category
field) or specify the filename. This would be quite useful when bulk uploading files.The text was updated successfully, but these errors were encountered: