dotnet / dotnet/aspnetcore

Per file size limit in multipart form

Open
#58,225 2 comments 4 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

As title says my suggestion is to add a per file size limit for multipart forms. Use case:
A user can upload an unlimited or limited number of files with a total size not exceeding 1GB, but each file must be up to 100MB.

### Describe the solution you'd like

Add an additional prop to `FormOptions`. So it can be configured globally:
```
services.Configure(options =>
{
options.MultipartBodyLengthLimit = 1024 * 1024 * 1024;
options.MultipartFileSizeLimit = 1024 * 1024;
});
```
or using `RequestFormLimits` attr
`[RequestFormLimits(MultipartBodyLengthLimit = 1024 * 1024 * 1024, MultipartFileSizeLimit = 1024 * 1024)]`

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.