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

small file can not be parsed? #3

Closed
wuzeru opened this issue May 17, 2016 · 2 comments
Closed

small file can not be parsed? #3

wuzeru opened this issue May 17, 2016 · 2 comments

Comments

@wuzeru
Copy link

wuzeru commented May 17, 2016

I find a bug.

A small file which maybe 9k can not be pushed into 'files'.I debug it and perhaps it returned before the stream was pushed into the files.


I get what's wrong.

image

the busboy closed before the writeStream open.

so if i code like this

function onFile(files, fieldname, file, filename, encoding, mimetype) {
  const tmpName = file.tmpName = new Date().getTime()  + fieldname  + filename;
  const saveTo = path.join(os.tmpDir(), path.basename(tmpName));
  const writeStream = file.pipe(fs.createWriteStream(saveTo));
    const readStream = fs.createReadStream(saveTo);
    readStream.fieldname = fieldname
    readStream.filename = filename
    readStream.transferEncoding = readStream.encoding = encoding
    readStream.mimeType = readStream.mime = mimetype;
    files.push(readStream);
}

then it work.

is it a bug or there is anyother reason why you code such as?

@m4nuC
Copy link
Owner

m4nuC commented May 26, 2016

Hi, I apologise for the late reply and thank you for reporting!

There is a reason why wait for open event. See #1

I will make some testing the next few days. Otherwise you are welcome to submit a PR.

abalhier pushed a commit to abalhier/async-busboy that referenced this issue Jun 8, 2016
@m4nuC
Copy link
Owner

m4nuC commented Jun 9, 2016

Fixed with #4

@m4nuC m4nuC closed this as completed Jun 9, 2016
m4nuC added a commit that referenced this issue Jun 9, 2016
Fixes #3 : Register event before reading uploaded file
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

2 participants