Upload images with Cloudinary, MongoDB and Express.

We will have to create a middleware that uploads a image to cloudinary and returns it’s image url

Create an account in cloudinary and choose programmable media.

Now go back to editor and create 3 variables in dotev file with these informations: CLOUD…


This content originally appeared on DEV Community and was authored by Raphael Machado

We will have to create a middleware that uploads a image to cloudinary and returns it's image url

Create an account in cloudinary and choose programmable media.

Now go back to editor and create 3 variables in dotev file with these informations: CLOUD_NAME, API_KEY, API_SECRET.
You get that from cloudinary dashboard.

cloudinary connection

Create a folder 'utils' with a 'cloudinary.js' file.

cloudinary.js code

Create a 'controller' folder with a 'cloudinaryMiddleware.js' file.

middleware code
Now you just have to import and place it in your REST API like this:

rest api code


This content originally appeared on DEV Community and was authored by Raphael Machado


Print Share Comment Cite Upload Translate Updates
APA

Raphael Machado | Sciencx (2022-07-13T15:04:55+00:00) Upload images with Cloudinary, MongoDB and Express.. Retrieved from https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/

MLA
" » Upload images with Cloudinary, MongoDB and Express.." Raphael Machado | Sciencx - Wednesday July 13, 2022, https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/
HARVARD
Raphael Machado | Sciencx Wednesday July 13, 2022 » Upload images with Cloudinary, MongoDB and Express.., viewed ,<https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/>
VANCOUVER
Raphael Machado | Sciencx - » Upload images with Cloudinary, MongoDB and Express.. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/
CHICAGO
" » Upload images with Cloudinary, MongoDB and Express.." Raphael Machado | Sciencx - Accessed . https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/
IEEE
" » Upload images with Cloudinary, MongoDB and Express.." Raphael Machado | Sciencx [Online]. Available: https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/. [Accessed: ]
rf:citation
» Upload images with Cloudinary, MongoDB and Express. | Raphael Machado | Sciencx | https://www.scien.cx/2022/07/13/upload-images-with-cloudinary-mongodb-and-express/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.