Skip to content

upload limit of filesize for multipart ignored #3584

Open
@tessus

Description

@tessus

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions