Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

request aborted when file is over 5 mb #29

Open
duanxianbo opened this issue Apr 24, 2018 · 1 comment
Open

request aborted when file is over 5 mb #29

duanxianbo opened this issue Apr 24, 2018 · 1 comment

Comments

@duanxianbo
Copy link

duanxianbo commented Apr 24, 2018

hello, I am facing a problem with skipper-better-s3, when I upload a file over 5 MB, it crash sailsjs server and give me an error like:
t IncomingMessage.onReqAborted (/home/duan/projects/ds_back_end/node_modules/multiparty/index.js:183:17)
at emitNone (events.js:106:13)
at IncomingMessage.emit (events.js:208:7)
at abortIncoming (_http_server.js:412:9)
at socketOnClose (_http_server.js:406:3)
at emitOne (events.js:121:20)
at Socket.emit (events.js:211:7)
at TCP._handle.close [as _onclose] (net.js:554:12)

I have my upload code as following:

`upload: (req, res) => {
const {fileName, previewName, coverName} = req.body;

async.waterfall([callback => {
  async.parallel([
    cb => {
      if (!fileName) {
        return cb();
      }

      req.file(fileName).upload(disAWS.uploadConfig(fileName, 'MUSIC'), (err1) => {
        if (err1) {
          return cb(err1);
        }

        cb();
      });
    },
    cb => {
      if (!previewName) {
        return cb();
      }

      req.file(previewName).upload(disAWS.uploadConfig(previewName, 'PREVIEW'), (err1) => {
        if (err1) {
          return cb(err1);
        }

        cb();
      });
    },
    cb => {
      if (!coverName) {
        return cb();
      }

      req.file(coverName).upload(disAWS.uploadConfig(coverName, 'COVER'), (err1) => {
        if (err1) {
          return cb(err1);
        }

        cb();
      });
    }
  ], callback);
}, (result, cb) => music.createMusic(req.body, req.ctx.payload.id, cb)], (err) => {
  if (err) {
    return res.negotiate(err);
  }

  res.created();
});`

and disAWS.uploadConfig is a function to generate skipper s3 config:

module.exports.uploadConfig = (fileName, key) => {
return {
adapter,
key: accessKeyId,
region,
maxBytes: Number.MAX_VALUE,
secret: secretAccessKey,
bucket: configPath.bucket,
dirname: folderMap[key],
saveAs: (__newFileStream, next) => {
return next(undefined, fileName);
},
onProgress: progress => console.log('Upload progress:', progress)
};
};

any help is appreciated, thanks in advance

@robertrossmann
Copy link
Member

Could you try not setting maxBytes and see if that helps? 🤔

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants