0

In my app (sails 0.12.0) I want to extend a limit of bytes send upon POST request. So I've followed the comments in this stackoverflow question

var skipper = require('skipper');
skipper.limit = 1024*1024*100;

middleware: {
    bodyParser: skipper
}

I still get an error:

 "data": {
    "code": "E_EXCEEDS_UPLOAD_LIMIT",
    "name": "Upload Error",
    "maxBytes": 15000000,
    "written": 15007474,
    "message": "Upload limit of 15000000 bytes exceeded (15007474 bytes written)"
  }

I've also tried to add the code below directly under module.exports.http and then I've tried to add it in the middleware only.

  bodyParser: (function () {
    var opts = {limit:'50mb'};
    var fn;

    // Default to built-in bodyParser:
    fn = require('skipper');
    return fn(opts);

  })

My question is: Why none of these codes work and how can I increase the limit. The solution can be not elegant.

Community
  • 1
  • 1
Danis
  • 1,978
  • 3
  • 16
  • 27

1 Answers1

3

Everything that you need - set

maxBytes

attribute in object of options to upload() method of skipper Upstream.

req.file('image').upload({maxBytes: 50000000}, function (err, uploadedFiles) {
     if (err) return res.serverError(err.message);
     if(uploadedFiles.length > 0) {
     // do with uploaded images what you want
      .....
     }
});
1nstinct
  • 1,745
  • 1
  • 26
  • 30