Domanda

I am trying to move to express 4.+ and I am having trouble figuring out what I should do about file uploads.

Migration docs says I need to come up w/ an alternative but they don't really give an example. They also dropped support for a reason, which file upload package should I use?

Also read that you should not attach a form upload to every post by using:

app.use(multer(...));

Is there a good way to attach these to just a particular route?

È stato utile?

Soluzione

formidable or busboy are options.

Expressjs 4.+ has lost this feature because it's not built on top of connect anymore.

Altri suggerimenti

I use connect-busboy. I could not get 'busboy' to work. Other packages I came across but have never played with are 'flow' and 'parted'. There is also a npm package 'mongoose-file' which seems to let you add a file upload path to a mongoose Schema for upload to server. It may be handy if you are uploading other data to a MongoDB?

Basic connect-busboy and Formidable example using Express V4.2: Node/Express file upload

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top