Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Why Do Some Images Always Have A UUID Appended?

Solved

Why Do Some Images Always Have A UUID Appended?

friendscottn
Shopify Partner
26 3 18

I noticed while uploading images via the fileCreate mutation that some images would have a UUID appended no matter what value I would specify for the duplicateResolutionMode.

 

mutation:

 

    mutation fileCreate($files: [FileCreateInput!]!) {
        fileCreate(files: $files) {
            files {
                ...file
            }
            userErrors {
              field
              message
            }
        }
    }

 

variables:

 

{
    "files": [
        {
            "alt": "Alt Text",
            "contentType": "IMAGE",
            "duplicateResolutionMode": "REPLACE",
            "filename": "some_image_thumb.jpg",
            "originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
        }
    ]
}

 

 

Accepted Solution (1)

friendscottn
Shopify Partner
26 3 18

This is an accepted solution.

The key was the "_thumb.jpg" at the end of the filename. If you change the filename by removing the "_thumb" you can work around the bug in the API and your REPLACE or RAISE_ERROR duplicateResolutionMode will be honored.

 

There is a similar bug for files ending in underscore followed by digits. For example: "_1000.jpg" and "_1000x600.jpg" as well. Removing this these trailing patterns from the filename field allows you work around this issue. The originalSource field can continue to have the "_thumb" or "_1000" patterns included.

 

So this will work:

{
    "files": [
        {
            "alt": "Alt Text",
            "contentType": "IMAGE",
            "duplicateResolutionMode": "REPLACE",
            "filename": "some_image.jpg",
            "originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
        }
    ]
}

The resulting upload will be at 

https://cdn.shopify.com/s/files/1/{ACCO/UNTN/UMBER}/files/some_image.jpg?v={timestamp}

View solution in original post

Replies 5 (5)

friendscottn
Shopify Partner
26 3 18

This is an accepted solution.

The key was the "_thumb.jpg" at the end of the filename. If you change the filename by removing the "_thumb" you can work around the bug in the API and your REPLACE or RAISE_ERROR duplicateResolutionMode will be honored.

 

There is a similar bug for files ending in underscore followed by digits. For example: "_1000.jpg" and "_1000x600.jpg" as well. Removing this these trailing patterns from the filename field allows you work around this issue. The originalSource field can continue to have the "_thumb" or "_1000" patterns included.

 

So this will work:

{
    "files": [
        {
            "alt": "Alt Text",
            "contentType": "IMAGE",
            "duplicateResolutionMode": "REPLACE",
            "filename": "some_image.jpg",
            "originalSource": "https:\/\/www.myimages.com\/some_image_thumb.jpg"
        }
    ]
}

The resulting upload will be at 

https://cdn.shopify.com/s/files/1/{ACCO/UNTN/UMBER}/files/some_image.jpg?v={timestamp}
Liam
Community Manager
3108 344 904

I'm glad you figured this out and thanks for coming back to post the answer!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

cchandeze
Shopify Partner
6 0 0

Hello, thx for your answer

I think it's the same for "-1000.jpg"... How do you know what's working and what's not ?

friendscottn
Shopify Partner
26 3 18

It's been a bit since I worked on this, but I think I logged out an error in my program when the file names before and after did not match

cchandeze
Shopify Partner
6 0 0

Ok so you tried and tried and when it didn't work you logged it and found a pattern.

Thx again for your answer to yourself 🙂