2021-09-09 11:39:47 +02:00
|
|
|
using Microsoft.AspNetCore.Http.Features;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
namespace Umbraco.Cms.Web.Common.Security;
|
|
|
|
|
|
|
|
|
|
public class ConfigureFormOptions : IConfigureOptions<FormOptions>
|
2021-09-09 11:39:47 +02:00
|
|
|
{
|
2022-05-09 09:39:46 +02:00
|
|
|
private readonly IOptions<RuntimeSettings> _runtimeSettings;
|
|
|
|
|
|
|
|
|
|
public ConfigureFormOptions(IOptions<RuntimeSettings> runtimeSettings) => _runtimeSettings = runtimeSettings;
|
|
|
|
|
|
|
|
|
|
public void Configure(FormOptions options) =>
|
2021-09-09 11:39:47 +02:00
|
|
|
|
2022-05-09 09:39:46 +02:00
|
|
|
// convert from KB to bytes
|
|
|
|
|
options.MultipartBodyLengthLimit = _runtimeSettings.Value.MaxRequestLength.HasValue
|
|
|
|
|
? _runtimeSettings.Value.MaxRequestLength.Value * 1024
|
|
|
|
|
: long.MaxValue;
|
2021-09-09 11:39:47 +02:00
|
|
|
}
|