Skip to content

Support either multipart or Body::sized #49

@emk

Description

@emk

Hello! I've converted a bunch of our internal production code over to reqwest in preparation for the arrival of async hyper. It's working really well, and thank you for providing this transition path.

Right now, I'm dealing with a problem with the BigML API. I'm trying to upload multi-gigabyte CSV data files as a MIME multipart form attachment. Unfortunately, BigML requires MIME multipart, and it doesn't support chunked transfer encoding. I have a workaround for the missing multipart support mentioned in #4: I create a custom Reader type that generates a simple multipart body.

Unfortunately, this doesn't quite work. I need to read the entire file into memory anyway, because reqwest's Body::sized method is unimplemented. And this is when our server code crashes.

I'd definitely be interested in preparing a PR that implements something like the following:

pub fn sized<R: Read>(reader: R, len: u64) -> Body

...or an equivalent impl<R: Read> Into<Body> for (R, u64) version.

I know that Read is a bit of a weird case in this brave new work of futures and tokio, but it's still a core Rust API for anybody not writing async code, and it might be good to support Read and sized data long term.

If that's really not interesting, I could take a look at multipart, but that's more complicated to do right (our little workaround only handles a single file attachment).

We have two short-term workarounds that will help minimize this problem in production, but we'll need to find a solution soon, even if that means switching to hyper (either the current released version or async).

Thank you for any advice and guidance you can provide!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions