Hi, I attempted to upload images to a product using a GraphQL mutation. While the query executes successfully, the Shopify admin shows an error: “Media upload failed Image: * Image: Media failed to process because the image could not be downloaded
,” and the image isn’t added to the product.
I’ve tried this with both productCreate
and productCreateMedia
mutations. The issue mainly occurs with products that have only one variant. I’m using a CDN-hosted image URL that loads correctly in both regular and incognito browser sessions.
Still, even though the image URL is accessible via browser, the upload fails through the API. Interestingly, if we repeat the same request a few times, it sometimes works.
Is there a way to reliably solve this issue or any recommended approach to avoid these upload failures?
1 Like
Hey @Diwakar_Dahal
Thanks for reporting this.
To help narrow down exactly what’s happening here, can you test uploading one of these same CDN image URLs directly through the Shopify admin interface (Products > Add media > Upload from URL)? If you see the same processing error there, then the issue is likely with how how the media is being processed, or something not working well with your CDN host, rather than the API implementation itself.
Additionally, I’d be curious to know if you get different results when using the staged upload approach outlined in our product media documentation where you first upload the file using fileCreate
and then reference it in your product mutations.
Hi @KyleG-Shopify
I was able to successfully upload images using the Shopify admin interface the URL. However, when I attempt to upload the same URL via the API, it fails and returns the same error without uploading. Below are the details of the Shopify admin and the image URL I used.
https://p16-oec-ttp.tiktokcdn-us.com/tos-useast5-i-omjb5zjo8w-tx/1c871309916541818dc72fe9160012bd~tplv-omjb5zjo8w-origin-jpeg.jpeg
When you are uploading via API, which way are you doing it? Via staged media upload mutation or passing the CDN url directly?
Looking at your url you also have the file extension at the end twice which is a little odd.
I am passing the CDN url directly while creating the product
Please could you try using the staged media uploads?
I wonder if the double extension in the cdn url is causing issues
1 Like
I don’t believe the issue is related to the double extension — the first “jpeg” is part of the filename, while the last one is the actual file extension. Interestingly, when I use the same CDN URL to upload the media directly from the Shopify admin, it works without any issues. And this issue seems to occur only with single-variant products.
Also, when I call productCreate
or productCreateMedia
multiple times, the upload sometimes succeeds after a few attempts. I’m now planning to try using productSet. Do you have any further suggestions or best practices for this approach?
Thanks for doing those tests.
For the greatest stability I would recommend using the staged upload approach keeping the media uploads separate from the product mutations.
Yes, please can you try staged media uploads? As per the documentation here Manage media for products
Yes, I’ve tested it using staged media uploads, and it worked exactly as expected.Thanks
1 Like