I'm just starting with meteor.
I've found, and added the 'multer' package:
meteor add pfafman:multer
Now, I wonder how to configure the server side of meteor to use.
In my plain node app, I use it like this:
app.use(multer({ dest: './uploads/',
rename: function (fieldname, filename) {
return filename+Date.now();
},
onFileUploadStart: function (file) {
console.log(file.originalname + ' is starting ...');
},
onFileUploadComplete: function (file) {
console.log(file.fieldname + ' uploaded to ' + file.path);
var fileName = file.name;
var done=true;
}
}));
What is the equivalent server code for this in Meteor?
pfafman's multer is nothing more than a wrapper around npm's multer (if you go through its source you'd realize all it really does is
and then export it as a global variable through
api.export('multer');
(He didn't even include any test cases, let along a demo.))In express,
app.use()
is used for adding middleware 'layers' to the middleware stack. Since nowmulter
is already a global variable accessible anywhere on the server (after you havemeteor add pfafman:multer
), you can just use it the way you do in express by calling it inMeteor.startup
:Note: this would create the
uploads
directory in