-
Notifications
You must be signed in to change notification settings - Fork 320
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
Support configuring the MaxRequestBodySize for the upload endpoint #863
Conversation
53eb1c5
to
a7b4a42
Compare
a7b4a42
to
0e2bb09
Compare
Thanks for taking a look at the PR @dluc! I noticed in your commit that the minimum of the configured value and public long? GetMaxUploadSizeInBytes()
{
if (this.MaxUploadSizeMb.HasValue)
{
return Math.Min(10, this.MaxUploadSizeMb.Value) * 1024 * 1024;
}
return null;
} Was the intent to limit the configurable upload size to a value lower than the out-of-the-box default? I was hoping to support increasing the maximum to support the uploading of larger documents. I can appreciate wanting to put a limit on how large the configured value could be if there are downstream limitations but allowing a value greater than the ASP.NET Core defaults would make the setting more useful. |
Hi @dluc. Can you provide feedback on the above issue related to this PR? It is currently only possible to reduce the maximum size of the request body to a value lower than the default. If you want to enforce a maximum configurable value, would it be better to enforce that through validation of the setting during startup? |
I too think that this should be Another point is related to the fact that the value is expressed in Megabytes. Is this the right choice? Typically this kind of property is always in bytes (like in the ASP.NET Core |
I'm hoping this was a typo and the value was intended to be something greater than I had the value as bytes in the original commit to align with the server options that users would be used to setting. Using bytes certainly does provide the finest granularity possible. Because the value is in a configuration file you don't get the benefit of using a multiplier like |
Confirming it's a typo - it should indeed be I still prefer managing the configuration in MBs because it aligns better with realistic usage, offers better readability, and sets more accurate expectations. Specifically, there are two different values at play:
|
I think that, in this case, we should use 1 as a lower bound, to handle all the scenarios. |
Motivation and Context (Why the change? What's the scenario?)
We have some important documents that need to be imported to Kermel Memory that are larger than the current ASP.NET Core default maximum request body size limit of 30 MB (~28.6 MiB).
aspnet/Announcements#267
It is not currently possible to set the
MaxRequestBodySize
from configuration making it impossible to override this limit when running Kernel Memory from the Docker container image.dotnet/aspnetcore#4765
High level description (Approach, Design)
This PR adds a new
MaxUploadRequestBodySize
property to theServiceConfig
class that defaults tonull
.null
the default ASP.NET CoreMaxRequestBodySize
continues to be applied as is currently the caseIHttpMaxRequestBodySizeFeature
featureThis allows for an explicit limit to be configured that may be less than or greater than the default ASP.NET Core limit.