Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fileSize limit bug #38

Open
sm2017 opened this issue Dec 22, 2018 · 20 comments
Open

fileSize limit bug #38

sm2017 opened this issue Dec 22, 2018 · 20 comments

Comments

@sm2017
Copy link

sm2017 commented Dec 22, 2018

I found that fileSize works well if we set it large enough , but when we have a small fileSize limit , it not works , for instance if you set fileSize=1024 or fileSize=1 , there is no limit , you can upload file with no size limit , I test it and I see that I can upload 5MB files

I guess , When we set fileSie limit less than highWaterMark it occures

@sm2017
Copy link
Author

sm2017 commented Dec 25, 2018

@juliangruber reply please

@sm2017 sm2017 closed this as completed Dec 25, 2018
@sm2017
Copy link
Author

sm2017 commented Dec 25, 2018

@tj reply please

@juliangruber
Copy link

I'm not maintaining this repo, check out https://github.com/cojs/busboy/commits/master for recent commit authors.

I agree that this is a bad bug! If you need a fix more urgent than the maintainers can or want to provide (remember, you're posting this around christmas), you can work on a fix on your own, create a PR and mention me again. It's way easier to merge a PR than fix it.

@sm2017
Copy link
Author

sm2017 commented Dec 26, 2018

I mention recent contributes for help

@dead-horse
@coderhaoxin
@fengmk2
@jonathanong

@juliangruber
Copy link

There's no need to mention either, if people are watching this repo they will get a notification, if not, they likely aren't interested in maintaining it.

Is this issue still relevant to you? If so, please reopen.

@sm2017 sm2017 reopened this Dec 26, 2018
@sm2017
Copy link
Author

sm2017 commented Dec 26, 2018

Reopened!

@dead-horse
Copy link
Member

dead-horse commented Dec 27, 2018

this module is a wrap of https://github.com/mscdex/busboy, I think you can try to find some solutions or suggestions in there.

@fengmk2
Copy link
Member

fengmk2 commented Dec 27, 2018

@sm2017 do you listen the file limit event or truncated property? https://github.com/mscdex/busboy/blob/master/lib/types/multipart.js#L220
It can detect the file stream had hit the fileSize limit.

@sm2017
Copy link
Author

sm2017 commented Dec 27, 2018

@fengmk2 As you are contribute to https://github.com/eggjs/egg-multipart
I am using egg-multipart too , same issue

@fengmk2
Copy link
Member

fengmk2 commented Dec 27, 2018

@sm2017 can you show me a demo code to reappear this problem on egg-multipart?

@sm2017
Copy link
Author

sm2017 commented Dec 30, 2018

@sm2017 can you show me a demo code to reappear this problem on egg-multipart?

@fengmk2 try this

// config/config.default.js
exports.multipart = {
  fileSize: 1024,
};
// app/controller/upload.js
const sendToWormhole = require('stream-wormhole');
const Controller = require('egg').Controller;

module.exports = class extends Controller {
  async upload() {
    const { ctx } = this;
    const stream = await ctx.getFileStream();
    await sendToWormhole(stream);
    ctx.status = 204;
  }
};

There is no size limit , but if you set

// config/config.default.js
exports.multipart = {
  fileSize: 100*1024,
};

we have MultipartFileTooLargeError: Request file too large error

@sm2017
Copy link
Author

sm2017 commented Jan 2, 2019

@fengmk2 Do you test demo code?

@sm2017
Copy link
Author

sm2017 commented Jan 13, 2019

@fengmk2 , @dead-horse please run demo code , we have same issue in egg-multipart too

@juliangruber
Copy link

Open source is free to use and comes without warranty (see the license). If you need an issue fixed quicker than maintainers can get to it, your best bet is to try to fix it yourself and submit a pull request.

@atian25
Copy link
Collaborator

atian25 commented Jul 31, 2020

@sm2017 change sendToWormhole to a fs.writeStream, it works fine

const stream = require('stream');
const { promisify } = require('util');
const pipeline = promisify(stream.pipeline);
const { writableNoopStream } = require('noop-stream');
const sendToWormhole = require('stream-wormhole');

 let fileStream;
    try {
      fileStream = await ctx.getFileStream({
        limits: {
          fileSize: '1mb',
        },
      });
      await pipeline(fileStream, writableNoopStream());
      ctx.body = fileStream.filename;
    } catch(err) {
      console.log('@@', err);
      await sendToWormhole(fileStream);
      ctx.body = err.message;
    }

@sm2017
Copy link
Author

sm2017 commented Jul 31, 2020

@atian25 You set 1mb limit , do you test lower limits? 1024 bytes?

@atian25
Copy link
Collaborator

atian25 commented Jul 31, 2020

@sm2017 yes, see atian25/egg-showcase#18

the router and test case

@StarpTech
Copy link

Hi, what's the status here? For me, it looks like busboy is not able to handle file size limitation correctly. @sm2017 test suite confirms my issues with it.

@sm2017
Copy link
Author

sm2017 commented Oct 12, 2020

@StarpTech I opened issue about 2 years ago! I really don't remember what happened

@StarpTech
Copy link

Thanks for responding.

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

No branches or pull requests

6 participants