I would like to configure the uploadable file size of the request from the appsettings.json on every controller method with different parameter, but I don't want to set it globally. How can I do it?
public long GetCatMaxFileUploadSize()
{
return _appSettings.Value.CatSettings.GetUploadFileSize;
}
public long GetDogMaxFileUploadSize()
{
return _appSettings.Value.DogSettings.GetUploadFileSize;
}
public long GetRabbitMaxFileUploadSize()
{
return _appSettings.Value.RabbitSettings.GetUploadFileSize;
}
...
[HttpPost]
[RequestSizeLimit(1000000)] //1MB -> set this value "dynamically" from appsettings.json
[RequestFormLimits(MultipartBodyLengthLimit = 1000000)]
public IActionResult CatConfigUploader([FromForm] IFormFile jSonFile){
...
}
[HttpPost]
[RequestSizeLimit(50000000)] //50MB -> set this value "dynamically" from appsettings.json
[RequestFormLimits(MultipartBodyLengthLimit = 50000000)]
public IActionResult DogConfigUploader([FromForm] IFormFile jSonFile){
...
}
[HttpPost]
[RequestSizeLimit(4000000)] //4Mb -> set this value "dynamically" from appsettings.json
[RequestFormLimits(MultipartBodyLengthLimit = 4000000)]
public IActionResult RabbitConfigUploader([FromForm] IFormFile jSonFile){
...
}
(I know, if I change the value in appsettings I have to restart the IIS, but this is better, than recompile the file.)