File upload from backend via API

Shopify Partner
20 1 4


When looking at fileCreate
The description says: "Creates file assets using an external URL or for files that were previously uploaded using the stagedUploadsCreate mutation. These files are added to the Files page in Shopify admin."

So I'm running stagedUploadsCreate and getting back resourceUrl, url, parameters
The resourceUrl looks like

Obviously, this is not this resourceUrl that I need to use with fileCreate since no file data have been sent. it's basically an empty shell at this point.

So I attempt to upload the file using the code sample provided by Shopify


const [{ url, parameters }] = data.stagedUploadsCreate.stagedTargets

const formData = new FormData()

parameters.forEach(({name, value}) => {
  formData.append(name, value)

formData.append('file', file)

const response = await fetch(url, {
  method: 'POST',
  body: formData


I'm getting the status code 201 and status message "Created".

So now I call the 
fileCreate endpoint with originalSource set to
The mutation result is successful but the image hasn't been uploaded:


    alt: 'TEST',
    createdAt: '2021-11-17T22:54:50Z',
    fileStatus: 'UPLOADED',
    preview: { image: null, status: 'UPLOADED' },
    fileErrors: []


What I am doing wrong? Do I need to upload the file to an S3 bucket before in order to get a correct url ?
I'd like to use Shopify only for file storage and would like to avoid a temporary solution in between. I know I could also upload the file to the assets folder of a theme but this is not what I want either.


Reply 1 (1)

Shopify Partner
5 0 2

I'm having same issue, have you solved this yet?