Upload files Sails JS Skipper v0.10.5

Tags: , , ,

I am uploading files with skipper, everything it’s working perfectly, but I have a problem with the option saveAs I am assigning it’s value by means of a function but it doesn’t work, how can I assign the value of req.param(‘titulo’) + file extension to the option saveAs?

var path = require('path');

module.exports = {


    var uploadOptions = {
        dirname: sails.config.appPath + '/assets/books',
        saveAs: function(file){
            return req.param('titulo')+path.extname(file.filename);
        maxBytes: 20 * 1000 * 1000

            return res.serverError(err);

    Book.create(req.params.all(),function bookCreated(err,book,next){
        if(err) {
        return res.redirect('/book/books');


I also really want to know if inside of the folder assets would be a good place to upload a pdf file to show it in my front end, ty.


I solved the problem by replacing the saveAs function:

saveAs: function(file){
    return req.param('titulo') + path.extname (file.filename);

with the following:

saveAs: function (__newFileStream, cb) {
    cb(null, req.param('titulo') + path.extname(__newFileStream.filename));

Source: stackoverflow