Actix-web: Multipart not streaming properly?

Created on 12 Apr 2019  路  7Comments  路  Source: actix/actix-web

As mentioned in #634 I am opening a separate issue for the chunking issue I have.

Using the multipart example in master, I cannot seem to get more than a single chunk when uploading a text-like file. Even a 3gb file will be in this fold a single time: https://github.com/actix/examples/blob/master/multipart/src/main.rs#L22
I have attached a 5MB text file as a sample below:

small.txt

However an image like https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Rust_programming_language_black_logo.svg/1024px-Rust_programming_language_black_logo.svg.png will get many chunks of random size, interleaved with some 1 byte chunk coming from actix itself?

I guess it is mostly 2 questions:

Most helpful comment

should be fixed in master

All 7 comments

This is issue in multipart implementation, I will fix it this weekend

Let me know when this is fixed, happy to help with testing!

should be fixed in master

After my preliminary testing it seems to work great and to be fixed!

Thank you very much x1000!

For the record the example is now at least 2x faster than the Go version for a 235MB mp3 file :heart_eyes:

It does look like it works very well now! The only thing is that the example seems to return immediately and returns a bogus value?

yes, it can be fixed by replacing the web::block part by:

web::block(move || {
    file.write_all(bytes.as_ref())
        .map_err(|e| {
            println!("file.write_all failed: {:?}", e);
            MultipartError::Payload(error::PayloadError::Io(e))
        })?;
    acc += bytes.len() as i64;
    Ok((file, acc))
})

(I've opened a PR: actix/examples#116)

@Keats btw we use jsonwebtoken in prod at azure iot.

Was this page helpful?
0 / 5 - 0 ratings