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

More flexible constraints #65

Open
tp971 opened this issue Oct 19, 2024 · 0 comments
Open

More flexible constraints #65

tp971 opened this issue Oct 19, 2024 · 0 comments

Comments

@tp971
Copy link

tp971 commented Oct 19, 2024

Assume I want to support really big file uploads (e.g. multiple gigabytes), but only for certain users. This runs into multiple problems with the current API:

  1. You can only limit the size of whole stream or whole fields, but not the limit of headers, so I think there should be a way to set a size limit for all headers in SizeLimit. This would allow only limiting the headers and leaving the size limit to the application, which is what my use-case needs.
  2. Maybe there should be a way to set a general limit for "text fields" (i.e. fields without a file_name) and a limit for "file fields" (i.e. fields with a file_name). Currently, this is supposed to be done with SizeLimit::per_field(), but this is not really viable for all use cases.
  3. Maybe it should be possible (I don't know how hard this is to implement) to change the size limit after constructing the Multipart struct.

I think implementing the first point (allowing to only limit headers) should be sufficient to handle most use-cases.

The last two points come from the observation that the API of many web-frameworks in Rust use some notion of "extractors", e.g. in axum, you define "handler functions" whose arguments implement FromRequest: https://docs.rs/axum/latest/axum/extract/multipart/struct.Multipart.html#example in this example, if you do a request to /upload, the Multipart (which is a wrapper around multer::Multipart), is constructed by axum before upload() is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant