question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multer is not writing the file directly in the folder

See original GitHub issue

Hello, I am uploading files dynamically (different folders based on need):

// Configure multer
let upload = multer({
  storage: multer.diskStorage({
    destination: (req, file, callback) => {
      let homefolder = req.body.folder;
      callback(null, homefolder);
    },
    filename: (req, file, callback) => {
      let filename = req.body.filename;
      callback(null, filename);
    }
  })
});

router.post('/upload', upload.single('file'), ctrlFileUploader.upload);

This is working well, the issue I have noticed is that multer doesn’t write the file there exactly, it kinda waits for the file to be uploaded completely and then starts writing the file to the folder. Is this normal or I am doing something wrong?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
msolano00commented, Oct 6, 2017

@LinusU I’ll do that an report back what I found.

0reactions
jonchurchcommented, Jan 25, 2020

If someone can try and repro this, or link an issue if this has been investigated, that would be 💯

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Multer storage is not uploading file on server directory
Try to use the absolute path to the storage location: cb(null, require('path').join(__dirname, '..', 'resources', 'uploads'));. instead:
Read more >
Multer: Easily upload files with Node.js and Express
Multer is a Node.js middleware for handling multipart/form-data that ... First, create a folder called file-upload-example , then create ...
Read more >
File Upload Using Multer in Node.js and Express.js
Here is a step-by-step guide to build a demo application for image and video file upload using Multer in NodeJS and Express from...
Read more >
File uploads using Node.js - CodeForGeek
You need to add that folder as a static path where your file is getting uploaded and once the client is trying to...
Read more >
Upload files to the Node.js server with Express and Multer
We can view the file now but, there is an issue we need to know about. We are exposing a folder of our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found