Solved

Product Image Upload using GraphQL without URL

LePong
Excursionist
25 1 19

Hi!

I'm building a private app that will have the ability to create products on the store. I understand that using GraphQL, I have to provide a URL to the product as opposed to being able to provide a base64 encoded "attachment" if using REST. I've seen it requested (and confirmed to be being worked on) that we be able to provide an attachment instead of a URL when using GraphQL, so that's not my question... my question is, is there a way to upload to the CDN instead of finding image hosting somewhere else, to then provide that URL for the product image? I rather not have my product images living somewhere else for the mere purpose of passing it along to the product during creation.

 

Thanks!

Accepted Solution (1)

Alex
Shopify Staff
1561 81 341

This is an accepted solution.

You can use our Admin GraphQL API's StagedUploadTargetGenerate mutation to initialize a storage bucket with your image file, which returns to you a src URL you can use to add the image(s) to resources:

 

https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/stageduploadtargetgenerate

 

Hope that helps, it definitely appears to solve the issue of having to upload to another service. Let me know if you have any questions, or if I've misunderstood what you're looking for.

 

Cheers.

 

The answer above has been updated for accuracy on July 3rd, 2019

Alex | 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 the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 3 (3)

Alex
Shopify Staff
1561 81 341

This is an accepted solution.

You can use our Admin GraphQL API's StagedUploadTargetGenerate mutation to initialize a storage bucket with your image file, which returns to you a src URL you can use to add the image(s) to resources:

 

https://help.shopify.com/en/api/graphql-admin-api/reference/mutation/stageduploadtargetgenerate

 

Hope that helps, it definitely appears to solve the issue of having to upload to another service. Let me know if you have any questions, or if I've misunderstood what you're looking for.

 

Cheers.

 

The answer above has been updated for accuracy on July 3rd, 2019

Alex | 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 the Shopify Help Center or the Shopify Blog

LePong
Excursionist
25 1 19
Amazing!
Thanks so much Alex. Sorry for the late reply. Haven’t been working on that project for a few weeks so haven’t been checking the forum. 😞
Thanks again!
binguyen858
New Member
4 0 0

How to upload image to shopify and access via url  ?

I want to upload with data image is base64 string. Thank !