Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Product Image Upload using GraphQL without URL

Solved

Product Image Upload using GraphQL without URL

LePong
Excursionist
25 1 20

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 343

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 343

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 20
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 !