I’m trying to make an application that requires image uploading and storing, I’m using Express, Mongoose and Multer and trying to upload to MongoDB. Currently when I try to upload an image, Multer does create a folder and store the image in that folder, but it doesn’t save the item to the database and it crashes the server giving the
Tag: multer
How to validate multiple file uploads with multer expressjs
I have a problem with express.js and multer when I try to upload 2 valid images and 1 example pdf to validate is all images, it will upload that two images into a folder, and then it will throw the error for pdf that is an invalid format, can I somehow validate first all images and then do the upload
How to rename file in Multer middleware to data I am sending in request
On a frontend I am generating unique ID for every order. Idea is to rename file which user uploads to orderId. Here is my request to server: Here is the server code: console.log(req.body) shows empty object in filename and orderId in app.post(). Here is how it looks: So this cannot be done as far as I understand inside filename. How
Node.js – How do I upload an image to Backblaze b2?
I am getting connect Request failed with status code 400 from b2.uploadFIle() Here’s what I tried to do: Step 1: Download backblaze-b2 node.js library and multer(to get image file in req.body) Step 2: Set up how I’m going to call my route in POSTMAN. I have attached an IronMan.png in my request. Step 3: Set up my code: I used
Multer – Cannot read property ‘buffer’ of undefined
I have a problem uploading an image file to my server, I watched some tutorials on YouTube about multer and I do exactly the same thing that is done in the tutorial and for whatever reason, I get an error: (“Cannot read property ‘buffer’ of undefined”), and req.file is also undefined. I googled for the error and found some people
Cannot POST image to my API Route from React.js
I am creating a MERN app in which I have created an api route /api/books where user can POST a book’s details with it’s image, and the data will be stored in MongoDB. I am using multer and it stores the image after encoding in binary format in the database. When I test it with postman, I works perfectly fine
Cannot read property ‘path’ of undefined while uploading image upload on the frontend(react)
I am trying to upload an image on the frontend, but this is not working, I am getting the error below When I log req.file on the backend and try to upload on the frontend, I get undefined in the console, but this gets logged for req.body Image upload works fine on the backend via Postman. Here is the frontend
multer npm: TypeError: Cannot read property ‘path’ of undefined
I have a problem uploading an image file to my server, I watched a tutorial on YouTube about multer and I do exactly the same thing that is done in the tutorial and for whatever reason I get an error: (“TypeError: Cannot read property ‘path’ of undefined”). I googled for the error and found some people having the same issue
How to find the size of the file in Node.js?
I am using multer for uploading my images and documents but this time I want to restrict uploading if the size of the image is >2mb. How can I find the size of the file of the document? So far I tried as below but not working. Can anyone please help me? Answer To get a file’s size in megabytes: