Using the multer library with cloudinary api - node.js

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.

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

Related

upload and read file in nodejs without any third party module like multer, express-fileupload, busyboy etc,

I'm currently learning nodejs file upload. I saw a lot of tutorials, but all the tutorials force me to use third-party module mainly multer. I need to upload and read files, but I need to do it myself
Multer uses busboy internally, busboy uses node writableStream api, if you want to understand how they are doing, go through busboy code. Unless you have some custom usecase and understand streams very well it's not recommended to use your custom implementation. https://github.com/mscdex/busboy/blob/master/lib/main.js

using backend files nodejs

Sorry, It might be very novice problem but I am new to node and web apps and just have been stuck on this for couples of days.
I have been working with a API called "Face++" that requires user to upload images to detect faces. So basically users needed to upload images to my webapps backend and my backend would do an API request with that image. I somehow managed to upload the files at my node's backend using tutorial provided below but now I am struggling how to use those image files. I really don't know how to have access to those files. I thought writing just the filepath/filename would help but it did not. I am really new at webapps.
I used tutorial from here: https://coligo.io/building-ajax-file-uploader-with-node/
to upload my files at back-end.
thanks
You can also use the Face++ REST API node client
https://www.npmjs.com/package/faceppsdk
As per in documentation it requires a live URL on web. Then you have to upload your files into remote location (You may upload files to a Amazon S3 Bucket)
And also you check the sample codes from Documentation where you can upload directly to Face++

File upload node.js express

I am using Node JS as web API server, for the front end, I am using Angular 4, Android and IOS. I have successfully implemented file upload using post request. I am exposing only one port outside. I need to implement file upload with a progress bar. I have only worked with POST and GET requests in past.I am not getting how to implement it on the server and send the progress responses to the front end. Additionally is there any other method that can be used.
It would be of great help if someone could help me with this process
For file upload you can use DropzoneJS. Since you are using Angular for front end use Dropzone for Angular.
I was looking into it and heard socket.io can be used to achieve the same. i need to user sharp package on the streamed data
For the server side, I use the built in express routers using multer. Multer parses multipart form data and uses callbacks that play very nicely with express routers.
Then for the UI you need an element that can upload multipart form data. If your using HTML 5 then you should be able to use just about any library that is out there. I personally use Vaadin uploads. It's a nice drop in element that does all the work for you. It even has a nice upload bar and status built in.

Image Upload : Base64 to server in post request or Express Js Middelware

I need to upload a local file to s3 and save its link in the database. Right now I am converting the image to base64 and sending it to my rails server, which saves it on s3 and returns a url. I send this URL in the next HTTP request. Now, how about I save it via express get a link and then use it for the request. What be the better approach? Using middleware or backend server?
For file upload, i suggest you to use multer middleware, because native multipart implementation is a little bit tricky. For interaction with amazon s3 middleware is used.
To send file somewhere else you could use pipes:
fs.createReadStream(rqPath).pipe(res);
In above example, file is read from local system and piped to response.
All mentioned modules could be find at NPM
If you're still trying to figure this out, I was struggling with the same issue, decided to POST binary data (converted from base64) directly in body without dealing with multipart forms, and whipped up the base64-image-upload package to make this easy.

CSV/Text file upload using node js

I need to create a function to upload CSV/txt file into mongodb using mean stack.
The function should be like i will upload a file. First it will check whether its in text/csv format than it will upload that to mongodb.
I searched on internet and couldnt find any good material. Anyone have any idea, Please share
I used angular-file-upload and wrote my own handler using multiparty for express.

Resources