Shopify Files API – Get CDN URL Immediately After Upload

Hello Guys,

In my Shopify public app, I have access to the read_files and write_files scopes. When a user uploads an image through my app, I want to store that image in Shopify Files.

Once the image is uploaded to Shopify Files, I want to get its Shopify CDN URL and store that URL in a metafield, so my app blocks can use the CDN URL directly without putting any load on my server.

However, it looks like Shopify does not immediately upload the file and return the CDN URL in the same API request.

What is the recommended approach for this?

Ideally, I want the entire process to happen from a single server request:

  1. User uploads an image in my app.

  2. My server uploads the image to Shopify Files.

  3. Shopify returns the CDN URL.

  4. My server immediately saves that URL in the appropriate metafield.

Is there a Shopify API or recommended flow that allows me to upload the file and get the CDN URL immediately, so I can save it to the metafield without requiring a separate polling/background request?

Any guidance or example implementation would be greatly appreciated. Thank you!

Hi,

From hitting the same wall: you can’t get the CDN URL in the same request. fileCreate returns fileStatus UPLOADED, not READY, and the URL only populates once Shopify finishes
processing. That’s the design, not a limitation to route around.

I ran into this doing product media on draft creation - the mutation succeeds, the media isn’t there yet, and anything that assumes it is will intermittently fail.

I think as per your question, you’ve ruled out polling, and I’d agree. The path I’d look at
instead is the files webhook topics - subscribe, and write the metafield from the handler when the file reaches READY. Your upload request returns immediately, nothing polls, nothing
blocks.

I think two things worth designing for either way:

Your app blocks need to handle the window where the metafield isn’t populated yet. It’s short but it exists, and users will hit it on the first upload.

Select mediaUserErrors (or the file equivalent) explicitly. Shopify can accept the mutation and reject the file, and without that selection you get a success response and no file.

Worth confirming the exact webhook topic names against current docs - I’m on the product media path rather than Files.