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

Allow access to headers in poem::web::Field #906

Open
Bednys94 opened this issue Oct 25, 2024 · 0 comments
Open

Allow access to headers in poem::web::Field #906

Bednys94 opened this issue Oct 25, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Bednys94
Copy link

Bednys94 commented Oct 25, 2024

Description of the feature

Hi, would be possible to access headers for poem::web::Field?
Due to limited resources on the device, when handling large file uploads, we need to write the multipart file stream to disk rather than loading it entirely into RAM. Ideally, we would like to make this decision based on the Content-Length header to determine whether the file can be temporarily stored in RAM or should be written directly to disk. However, since headers are private, we are unable to access the Content-Length directly.

Thank you

Code example (if possible)

async fn parse_from_multipart(field: Option<poem::web::Field>) -> ParseResult<Self> {
    match field {
        Some(field) => {
            let content_length = field.headers().get("Content-Length"); // or field.get_header(header::CONTENT_LENGTH)
            // ... rest of code ...
        }
        _ => {
            // Handle None case if necessary
        }
    }
}
@Bednys94 Bednys94 added the enhancement New feature or request label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant