New Files API can read files, but can it write files?

Solved
baberuth22
Excursionist
16 0 3

I'm reading files using graphQL, but can I POST and write files as well?   

Is there a write files permission?

0 Likes
L_J_K
Shopify Staff
Shopify Staff
139 15 24

This is an accepted solution.

Hey @baberuth22 

Indeed, there is a write_files permission in the GraphQL Admin API - the documentation for the fileCreate fileDelete and fileUpdate mutations can be found here. Hope that helps -  thanks!

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
0 Likes
baberuth22
Excursionist
16 0 3

@L_J_K Thanks!   Can file create accept an attachment like assets create?

0 Likes
L_J_K
Shopify Staff
Shopify Staff
139 15 24

Hey @baberuth22 

So for files create, you can add Media like Images for example,  first you'd have to action  the stageduploadscreate mutation(docs).

 You'd receive a  "resourceUrl" returned in response from the stagedUploadsCreateMutation.

Then you'd pass that"resourceUrl" into the originalSource  input mentioned in the FileCreate docs(here) and the files should be uploaded to the Files page in the Shopify Admin. Ensure your app has write files permissions too Hope that helps!

| API Support @ Shopify |
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!