У меня есть файл на столе, который будет отправлен в API для обработки некоторых данных формы, он всегда будет возвращать 413 Request Entity Too Large, сам файл равен 10 МБ, он пытался загрузить его из ожившего API swagger и он был загружен без каких-либо ошибок, я использую. net core 3.1 здесь код для отправки
HttpClient uploadClient = new HttpClient();
MultipartFormDataContent form = new MultipartFormDataContent();
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("userId", userVideo.CreatorIdentifier.ToString());
parameters.Add("Filename", $"{userVideo.MediaIdentifier}.mp4");
HttpContent DictionaryItems = new FormUrlEncodedContent(parameters);
form.Add(DictionaryItems, "model");
var stream = new FileStream(videoPath, FileMode.Open);
HttpContent content = new StringContent("");
content.Headers.Add("Content-Disposition", $"form-data; name=\"
{userVideo.MediaIdentifier}.mp4\"; filename=\"{userVideo.MediaIdentifier}.mp4\"");
content = new StreamContent(stream);
form.Add(content, $"{userVideo.MediaIdentifier}.mp4");
uploadClient.DefaultRequestHeaders.Add("authorization", accessToken);
uploadClient.DefaultRequestHeaders.Add("api-version", "2");
var uploadResponse = uploadClient.PostAsync("api url", form).Result;
var k = uploadResponse.Content.ReadAsStringAsync().Result;
я попытался добавить это в программу .cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.Configure<KestrelServerOptions>(
context.Configuration.GetSection("Kestrel"));
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureKestrel(options =>
{
options.Limits.MaxRequestBodySize = null;
});
});
и добавил web.config с maxRequest
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime maxRequestLength="51200" executionTimeout="300"/>
</system.web>
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<system.webServer>
<handlers>
<remove name="aspNetCore" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44344" />
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
<security>
<requestFiltering>
<!-- This will handle requests up to 50MB -->
<requestLimits maxAllowedContentLength="999999999" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
, но ничего не работает, и я продолжаю получать ту же ошибку
спасибо