How to upload Image to Cloudinary Node JS | Cloudinary image upload node...

Hello and welcome back to our series on Node JS tutorials. In our, last video we talked about uploading a file or multiple files using express-upload.  Today, we'll go over how to  upload image to cloudinary.


At this point, many of you wondering what is cloudinary? Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline.

Try it right away, the signup link is-
~----~----------------~------------------~---------------~-----------------------~
https://cloudinary.com/users/register/free
~----~----------------~------------------~---------------~-----------------------~
Signup for the free account so that you can try uploading images.

To install coudinary. Simply run the command-

                    npm i cloudinary

Once installed,  set the cloud_name, api_key and api_secret parameters. Pass them in cloudinary config method. Take out there values from cloudinary portal.

Now, open the editor-

Require the cloudinary library:

                  var cloudinary = require('cloudinary');

Inside the POST method we will write the logic to upload the file. But before that we'll o one more configuration. We'll set the useTempFiles true for express-fileupload. Setting it true means Images will be first uploade to system's temp folder. So, we have set bothe the configuration. Now, call upload method of cloudinary uploader, as follow-

                    cloudinary.uploader.upload(tempFilePath, callback)

It has two parameters, temp file path and the callback. Callback has againn two parameters- err and result. err has some value if there is some problem while uploading the image. result has some value and error is null, if the image is uploaded successfully.


Thank you for listening!
--
Please like my social media page:

https://www.facebook.com/saigraceschool
https://twitter.com/saigraceschool
https://www.instagram.com/saigraceschool
https://www.youtube.com/c/renurawat?sub_confirmation=1

To Get Regular Content Updates-

https://www.youtube.com/c/renurawat?sub_confirmation=1

Comments