Bulk Upload Image Using Asset API

Highlighted
Shopify Partner
97 4 32

Working on a nice little app that needs to upload quite a few (rather small) images to the main theme of a Shopify store.

 

Main idea:

 

1. Have all the images present in my assets directory on the back-end side of my app (Node.js using Koa and Koa Router)

2. Have a route (i.e. a Koa route) that has the access token required to call the API

3. Run a loop that uploads all files once to the current theme using the endpoints specified in https://help.shopify.com/en/api/reference/online-store/asset

 

This is a rather slow operation if we're talking about hundreds of assets (even if they're rather small), and it's blocking since I need all assets to be available to my front-end (I'm generating liquid on-the-fly using asset URLs that are created by the asset upload). 

 

Is there some way to bulk upload all images in one piece, without downloading the theme, editing it and re-uploading it?

Building custom, public-facing Shopify Apps for various niches. Ping me with your app ideas!

My Apps:
* Countries We Ship To Button (Free!) - Show your customers where you ship to with a crisp button + pop-up!


My Tutorials:
* Get Notified When New Comments Are Added To Your Shopify Blog (Free!) - A quick & easy tutorial to set up a free web-service that e-mails you when you get a new comment on your Shopify blog!
0 Likes
Shopify Staff
Shopify Staff
28 5 4

Hi @KidOnPoint,

 

Unfortunately, there is currently no way to bulk upload assets via the API. 

 

It seems like your application is currently downloading, modifying, and re-uploading the entire theme for each image, which as you have mentioned, is a very arduous operation. Although it is still not optimal, if you are aware of the theme templates that you are updating, it could potentially be faster to simply update these templates individually since you are able to specify the asset that needs to be updated and provide an src to specify the image that needs to be uploaded to Shopify. This is documented here: https://help.shopify.com/en/api/reference/online-store/asset#update-2019-10

 

Cheers 

0 Likes
Shopify Partner
97 4 32

Hey @sd_ ,

 

Thanks for the response.

 

I'm afraid I have no clue as to which theme will be used by my customers, so the src approach might not work here.

Thanks for the heads up on the idea though!

 

 

Building custom, public-facing Shopify Apps for various niches. Ping me with your app ideas!

My Apps:
* Countries We Ship To Button (Free!) - Show your customers where you ship to with a crisp button + pop-up!


My Tutorials:
* Get Notified When New Comments Are Added To Your Shopify Blog (Free!) - A quick & easy tutorial to set up a free web-service that e-mails you when you get a new comment on your Shopify blog!
0 Likes