Search code examples
node.jsexpressfile-uploadmultercloudinary

Using the multer library with cloudinary api


Good day everyone.

I'm trying to upload a file to my cloudinary through a nodejs backend(already done a similar project). In my first project i followed steps on youTube tutorial using Multer and Cloudinary api. Although i don't fully understand what i did but after checking out the docs on cloudinary, i was wondering if using the multer library was necessary and why?

cloudinary.v2.uploader.upload() //uploads the file

Thanks for your contributions.


Solution

  • You don't need to use Multer specifically but where there's a POST request coming from your frontend form to the backend, and then you're sending a file from that backend to a remote service like Cloudinary, it's common to use some piece of middleware to take the file(s) from the form and make them available to your code for further use, and Multer is a very common library used for that purpose

    There are several other libraries you could use for this instead - For example, Cloudinary's Node SDK ships with a simple web application example that uses the multiparty library via a connector, and the README for that project recommends another library called busboy for the same purpose - anything that takes multipart form data and makes the files available to your code can work here