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

Rewrite Multipart support using multipart-async #89

Open
abonander opened this issue Nov 28, 2018 · 3 comments
Open

Rewrite Multipart support using multipart-async #89

abonander opened this issue Nov 28, 2018 · 3 comments
Labels
feature A feature that's ready for implementation

Comments

@abonander
Copy link

@liufuyang did an excellent job implementing the current multipart support and I'm flattered he chose my crate, but I'm worried about the scalability of collecting the entire request body to Vec<u8>, as you typically don't want to keep whole files in memory.

I have multipart-async which is designed to parse a multipart body from an async stream but it has languished a bit as I was waiting for the futures churn to settle and then I kind of forgot about it.

I'll be coming back to it and fixing it up, and I'd be glad to consult on/mentor a refactoring of Tide's multipart support to use it, or even another crate if there is one.

@liufuyang
Copy link
Contributor

Thank you @abonander. I would like to provide some help refactoring it when it is ready (Especially if you or someone can mentoring me 😄)

@alexesmet
Copy link

alexesmet commented Feb 19, 2021

Is there a possibility to use @abonander's multipart-async with current (v0.16.0) version of tide to parse multipart body of a request?

The main obstacle is that tide::Body's reader is futures::io::AsyncBufRead (to be specific: Box<dyn AsyncBufRead + Unpin + Send + Sync + 'static>), while multipart_async::server::Multipart::with_body(...) accepts futures::stream::Stream, and I can't find a way to convert the AsyncBufRead into the Stream.

I tried implementing some kind of adapter that would store buffered values from AsyncBufRead and implement Stream, but looks like I'm not experienced enough to do that.

@jbr
Copy link
Member

jbr commented Feb 19, 2021

I'm not sure if it will work with that multipart library, but you can get a stream from a Read/AsyncRead with https://docs.rs/async-std/1.9.0/async_std/io/prelude/trait.ReadExt.html#method.bytes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A feature that's ready for implementation
Projects
None yet
Development

No branches or pull requests

5 participants