Image not saving with productCreate query

Solved

Image not saving with productCreate query

steve_m_
Shopify Partner
1 0 1

Hello!

 

We create Shopify products from data we receive from suppliers, but product images from a certain host will not save.

 

An example of a URL that does not save: https://media.hdfiles.in:8520/HD4/imaged/4447780134/still.jpg. It appears to be served with the correct Content-Type (image/jpeg).

 

productCreate(input: {
title: "media files",
images:
{
altText: "hi!",
src: "https://media.hdfiles.in:8520/HD4/imaged/4447780134/still.jpg"
}
}

I can create a product with the above query with no errors, but there will be 0 images. I can also create products with image URLs from other places and the images are saved correctly.

 

An example of an image URL that works: https://d1g2oudknjs8jf.cloudfront.net/prodpolweb/imgfiles/l9jb11njp149.JPG

 

Could there be a server-side setting on the image host preventing Shopify from saving the image to its own CDN?

 

Thanks for any insight!

 

Edit: When adding the failing image in the Shopify UI via URL, I am able to see a Content Security Policy error in the developer console. This community post suggests that the host port has to be 443 for it to work in Shopify. Is this true?

 

Content Security Policy: The page’s settings blocked the loading of a resource at https://media.hdfiles.in:8520/HD4/imaged/4447780134/still.jpg (“default-src”).

 

— Steve

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 498

This is an accepted solution.

Hi @steve_m_ 👋

 

Thanks for sharing the image link! Testing this myself, it looks like the API successfully creates the media object, but the import has trouble processing the image from this host with a custom port. The port permissions will likely need to be adjusted on the server to make the image accessible via port 443 as you mentioned. Alternatively, images can be uploaded to Shopify CDN with the staged upload process.

 

Hope that helps!
 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

View solution in original post

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 498

This is an accepted solution.

Hi @steve_m_ 👋

 

Thanks for sharing the image link! Testing this myself, it looks like the API successfully creates the media object, but the import has trouble processing the image from this host with a custom port. The port permissions will likely need to be adjusted on the server to make the image accessible via port 443 as you mentioned. Alternatively, images can be uploaded to Shopify CDN with the staged upload process.

 

Hope that helps!
 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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