Uploading Images in Node.js with the Cloudinary Node SDK - Dev Hints

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
one of the most important parts of your image and video workflow is actually getting those images and videos to your cloudinary media library so we'll see how we can use the node SDK to easily upload one or multiple images with the node SDK uploader once the cloudinery node module is installed imported and configured we wouldn't be able to upload this local image as well as any other image in our directory we can start off by running cloudinary.uploader.upload where inside we can pass in an argument of that image path now be sure to take note of how I'm referencing that path to be sure that you're referencing the actual file in your file system but with that line I can chain on a then statement where I get my result so I can actually console log out that result to see how it works and once I run that script I can see that I successfully logged out the result of that upload I can now even open up that URL and see my new beautiful picture of a galaxy on my cloudinery account if you alternatively want to use the async await syntax what we can do is set up a self-invoking function we're going to Define async function run which I need to say that I want to invoke that function immediately where I can first get rid of that result statement I'm going to copy that uploader into my run function I'm going to add an await as as well as a constant of result so I can get that same result and finally let's log out that result we're again running the same upload I get a similar result but this time it's a separate upload and just as a quick note depending on the Node version you're using you may be able to use the top level await syntax but what if we instead wanted to upload multiple images we can run a function such as four const image of images where inside I'm going to run that same result code where what's going to happen is it's going to Loop through all the images inside of my array and then for each of those images it's going to do the same exact thing and use the uploader to upload my image so we can more easily see the output of all of our different results how about instead I only log out the secure URL and as that script runs we can see that we get an upload result for every single one of those images now finally we're uploading using their local file paths but the uploader takes in other formats rather than just the local path for instance we can pass in a base64 data URI or I can can even copy the image URL and pass that URL directly into the uploader which easily gives me a way to upload images that exist on other servers to my cloudinary account to learn more about uploading assets with cloudnery with the node SDK head over to the documentation where you can find more examples as well as the upload API documentation where you can find all the different options and parameters available for the SDK so in review in order to upload images to our Cloud array account using the node SDK we can pass in all of our images as the path or even the URL into the uploader which gives us an easy way to get our files into our cloudery account from node
Info
Channel: Cloudinary
Views: 13,361
Rating: undefined out of 5
Keywords: node upload image, upload image nodejs, upload image node, upload image to cloudinary node js, upload image in node js api, cloudinary image upload node js, cloudinary node js, cloudinary node sdk, uploading images to cloudinary, upload multiple images to cloudinary, cloudinary upload api, cloudinary upload node js, cloudinary upload multiple images node js, cloudinary uploader, cloudinary upload file, image upload in node js, multiple image upload in node js, cloudinary
Id: hGzVY88q8I0
Channel Id: undefined
Length: 3min 13sec (193 seconds)
Published: Tue Apr 04 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.