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.

can we stop changing the way multer setup please ? im banging my head

See original GitHub issue

This used to work inside a route now it is no longer working

var handler = multer({

                dest: __base + 'uploads/images/',

                onFileUploadStart: function (file) {
                    // You now have access to req
                    console.dir(req);
                    console.log(file.fieldname + ' is starting ...')
                },

                onFileUploadComplete: function (file) {
                    console.log(file.fieldname + ' uploaded to  ' + file.path)
                    var asset = new Asset();
                    asset.path          = req.files.file ? req.files.file.path.replace('uploads','') : '';
                    asset.type          = req.params.type;
                    asset.base64_data   = req.body.base64_data ? req.body.base64_data : '';

                    asset.save(function(err, asset_data) {
                        if (err)
                            res.send(err);

                        res.json({ message: 'Asset created!', asset_data: asset_data });
                    });
                }

            });

            handler(req, res);

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gabeiocommented, Jul 25, 2015

TLDR; read the new readme for the new major version changes in multer (which are very minor) and learn the semver major version meaning.

The point behind having major version number changes is that it is not backwards compatible if you wish to use the older version we are not stopping you. But there are significant benefits to upgrading including that I by myself can not DoS your server by filling your hard drive in (your available hard drive space/your internet speed). As such these changes need a different API which you will need to learn, if you are not willing to learn new APIs when they change I can not help you. In essence you basically are trying to tell use to stop updating multer by telling us to not change anything.

0reactions
LinusUcommented, Aug 17, 2015

You were actually using DiskStorage all along 😃

multer({ dest: './photos/' })

is a shorthand for

multer({ storage: multer.diskStorage({ destination: './photos/' }) })

Ahh, I understand. It really refers to the filename parameter to the diskStorage function. Should probably clarify that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express multer middleware
Multer is a node.js middleware for handling multipart/form-data , which is primarily used ... NOTE: Multer will not process any form which is...
Read more >
Nodejs Express 4 Multer | Stop file upload if user not ...
Express is configured to use passport as auth middelware, but I cannot find a way to prevent file upload if the user is...
Read more >
How to use Node.js, Express.js and Multer Restful API for ...
A short step by step tutorial on Restful API for Image Uploader using Node.js, Express.js, and Multer. We are using the form multipart/form-data...
Read more >
How to upload file using Multer in Express.js
I am sure you have wondered how to upload files in your Node.js application. ... 1) Install express and multer, and create your...
Read more >
All Stories - The Provincetown Independent
I'm the one who's supposed to be asking questions as part of my ongoing ... EASTHAM — A new road is being cut...
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