mscdex / busboy

A streaming parser for HTML form data for node.js
MIT License
2.84k stars 213 forks source link

doc for write() and end() #301

Closed sven5 closed 2 years ago

sven5 commented 2 years ago

Some documentation on how and when to use write() and end() would be really helpful. Thanks

mscdex commented 2 years ago

Can you elaborate a bit? Those are just the normal node.js writable stream methods. You shouldn't need to use them though if you are feeding busboy data from another (readable) stream, in which case you can use something like pipe() to automatically handle writes and backpressure.

sven5 commented 2 years ago

ah ok, now I see, thanks. We have kind of special use case here, we're using busboy in Azure functions. Especially, we're using this library as a helper for dealing with multi-part form data in an Azure function.

mscdex commented 2 years ago

The only usual hangup people have with cloud functions is realizing that the request body is already buffered somewhere by the cloud function SDK, so pipe() ends up doing nothing (when using the examples).

Aside from that, just make sure you always call .end() to be on the safe side.

Lonolf commented 1 year ago

I thank you for the amazing library you provide, but I had the same problem and lost 4 hours of work before finding about the .end().

In the end I found the correct code on a stackoverflow request (https://stackoverflow.com/questions/73217059/busboy-missing-file-data) about something else. I'm a Front-end developer mainly, so I didn't know about .write() and .end()

mscdex commented 1 year ago

@Lonolf Just as a heads up, write() and end() are a standard part of node.js streams, so you may find yourself using them again if you work with streams.