-
Notifications
You must be signed in to change notification settings - Fork 863
Specify value for custom fields on the File type when uploading files #174
Comments
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
}
} |
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 |
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 :) |
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. |
+1 for file upload with additional metadata in a single request. |
I would also love to see something like this. Adding other metadata to the body of the request shouldn't be too tricky, right? |
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. |
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. |
This issue has been moved to graphcool/graphcool-framework. |
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: