Download Sails JS Skipper v0.10.5 Files
I upload files with skipper, everything works fine, but I have a problem with save parameter. I assign its value using a function, but it doesn't work, how can I assign the value to req. param ('titulo') + file extension for saveAs option?
var path = require('path');
module.exports = {
'save':function(req,res,next){
var uploadOptions = {
dirname: sails.config.appPath + '/assets/books',
saveAs: function(file){
return req.param('titulo')+path.extname(file.filename);
},
maxBytes: 20 * 1000 * 1000
}
req.file('archivoPath').upload(uploadOptions,function(err,files){
if(err){
return res.serverError(err);
}
else{
console.log(files);
}
});
Book.create(req.params.all(),function bookCreated(err,book,next){
if(err) {
console.log(err);
}
return res.redirect('/book/books');
});
}
};
I also really want to know if inside folder files would be a good place to download the PDF to show in my interface.
+3
source to share
1 answer