Heyy Good People,
Recently we are introducing image compression feature in our app. We are using fileUpdate Mutation to upload the compressed file. Everything is working smoothly.
Afte compression, we are deleting the file from our S3 Bucket. Now, sometimes we are seeing the issue “Thumbnail Upload Failed” whenever we go to product edit page.
Is this related to file deletion? Though I am confirming that we delete the file after process is completed asynchronously.
Hey @illusionist3886! This looks like a timing issue with when you’re deleting from S3. When you call fileUpdate with an external URL, Shopify downloads and processes the image asynchronously - that includes generating thumbnails and optimizing for different sizes. If you delete from S3 before that’s done, we can’t complete the processing.
The key is checking the fileStatus field before deleting. After calling fileUpdate, poll until the status is READY:
query CheckFileStatus($id: ID!) {
node(id: $id) {
... on MediaImage {
id
fileStatus
}
}
}
The fileStatus will be UPLOADED, PROCESSING, READY, or FAILED. Only delete from S3 once it’s READY.
Are you currently checking the file status before deletion? If you’re already confirming READY and still seeing “Thumbnail upload failed”, can you share a few x-request-ids from your fileUpdate calls? I can check our logs to see what’s happening. Cheers!
That’s perfect explanation. But what to do for Collection and Article as those are not treated as MediaImage and therefore we cannot check fileStatus.
Good question - Collection and Article images work differently from product media, so you can’t check fileStatus on them.
A workaround would be to upload your compressed image via fileCreate first, wait for fileStatus: READY, then grab the Shopify CDN URL from the file’s preview.image.url field. Use that CDN URL in your collectionUpdate or articleUpdate call. Since the image is already fully hosted on Shopify’s CDN at that point, you can delete from your S3 bucket immediately after fileCreate returns READY - no timing issues.
# 1. Upload and wait for READY (same as you're doing for products)
query GetFileCDNUrl($id: ID!) {
node(id: $id) {
... on MediaImage {
fileStatus
preview {
image {
url # Use this in collectionUpdate/articleUpdate
}
}
}
}
}
# 2. Then use the CDN URL for collections/articles
mutation UpdateCollectionImage {
collectionUpdate(input: {
id: "gid://shopify/Collection/123"
image: {
src: "https://cdn.shopify.com/s/files/..." # CDN URL from step 1
altText: "..."
}
}) {
collection { id image { url } }
userErrors { field message }
}
}
It’s an extra step, but it gives you the same pattern you’re using for products where you know the image is fully processed before referencing it anywhere else.
1 Like