Skip to content

upload limit of filesize for multipart ignored #3584

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

Open
tessus opened this issue Feb 22, 2025 · 0 comments
Open

upload limit of filesize for multipart ignored #3584

tessus opened this issue Feb 22, 2025 · 0 comments
Labels
A-multipart project: actix-multipart needs-investigation

Comments

@tessus
Copy link

tessus commented Feb 22, 2025

Expected Behavior

total_limit should be honored.

        App::new()
            .app_data(Data::clone(&config))
            .app_data(Data::new(http_client))
            .app_data(
                MultipartFormConfig::default()
                    .total_limit(
                        Byte::parse_str(server_config.max_content_length.to_string(), true)
                            .expect("cannot parse byte")
                            .as_u64()
                            .try_into()
                            .unwrap(),
                    )
                    .memory_limit(10 * 1024 * 1024)
                    .error_handler(handle_multipart_error),
            )
            .wrap(Logger::new(
                "%{r}a \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\" %T",
            ))

Current Behavior

total_limit is ignored.
We also tried the middleware approach, but it doesn't work. With the middleware, you get an error message only AFTER the entire file has been uploaded.
With total_limit nothing happens at all. The file is just uploaded, no matter the size.

Possible Solution

I do not know.

Steps to Reproduce (for bugs)

  1. for middleware: git master https://github.com/orhun/rustypaste/commits/master/
  2. for total_upload: fix(server): upload limit orhun/rustypaste#360
  3. start rustypaste server
  4. upload file larger than max specified in config

Context

I have searched the documentation, Stackoverflow, and other websites. Unfortunately all the info I found was either not helpful or did not work.

If this is not a bug, please convert it to a discussion.

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.85.0 (4d91de4e4 2025-02-17) doesn't matter, the problem has existed for a long time
  • Actix Web Version: 4.9.0
@robjtede robjtede added needs-investigation A-multipart project: actix-multipart labels Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-multipart project: actix-multipart needs-investigation
Projects
None yet
Development

No branches or pull requests

2 participants