Product Image Upload using GraphQL without URL

Solved
Highlighted
Excursionist
24 1 2

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!

0 Likes

Success.

Shopify Staff
Shopify Staff
1555 79 240

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

2 Likes
Excursionist
24 1 2
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!
0 Likes
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 !

0 Likes