[JavaScript] Upload Multiple Images at Once Using Cloudinary’s Upload API

Jonathan_Sexton Member, Cloudinary Staff Posts: 3
edited August 2022 in Developer APIs

If you're working in the Node.js ecosystem and want to upload multiple assets to your Cloudinary account, using our Upload API is going to be your best bet.

First, ensure you have the most up to date version of Node.js

Next, let's use the Cloudinary Node SDK to simplify our implementation. Our amazing documentation team has built some fantastic quick start guides that I would recommend using.

Now, let's get your environment setup with your API Key and API Secret Key (or using the environment variable we provide for you in the console):

I've required the library and then set my config to match my credentials which were found in the console from above:

The secure parameter in the above screenshot returns HTTPS URLs.

Now we want to add our images to an array. I've manually added the path and file name to my array for simplification. However, there are different ways to automate this step if your use case calls for that:

Perfect! Now that we have our config set and our image array populated, let's iterate through the array and make our upload call:

Here are the required parameters and the optional parameters for the upload call.

This is the basic example and if your use case needs it you can absolutely use async/away or a JavaScript promise here as well. But for simplicity's sake I've kept this example very generic.

Now, all we have to do is run the node <directory/file name> in the command line to get our response from the API:

Success! Now we can check our Media Library to see that the assets were indeed uploaded successfully:

I hope this has helped and that you've learned just how easy it is to get assets into your Cloudinary account using our Upload API and any number of the SDKs we provide.

If you run into any issues, our amazing Support team is always here to help!