V10: AllowedUploadFiles appsetting not working (#13408)
* Add new Settings * Use new settings instead of old ones * Implement AllowedUploadedFiles value to be copied to AllowedUplayedFileExtensions * Obsolete old settings * Rename DisallowedUploadFileExtensions * Implement same fix for DisallowedUploadFiles * Use new settings for backoffice server variables * Update the correct setting Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
@@ -119,6 +119,32 @@ public static partial class UmbracoBuilderExtensions
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Remove this in V13
|
||||
// This is to avoid a breaking change in ContentSettings, if the old AllowedFileUploads has a value, and the new
|
||||
// AllowedFileUploadExtensions does not, copy the value over, if the new has a value, use that instead.
|
||||
builder.Services.Configure<ContentSettings>(settings =>
|
||||
{
|
||||
// We have to use Config.GetSection().Get<string[]>, as the GetSection.GetValue<string[]> simply cannot retrieve a string array
|
||||
var allowedUploadedFileExtensionsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.AllowedUploadedFileExtensions)}").Get<string[]>();
|
||||
var allowedUploadFilesValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.AllowedUploadFiles)}").Get<string[]>();
|
||||
|
||||
if (allowedUploadedFileExtensionsValue is null && allowedUploadFilesValue is not null)
|
||||
{
|
||||
settings.AllowedUploadedFileExtensions = allowedUploadFilesValue;
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: Remove this in V13
|
||||
builder.Services.Configure<ContentSettings>(settings =>
|
||||
{
|
||||
var disallowedUploadedFileExtensionsValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.DisallowedUploadedFileExtensions)}").Get<string[]>();
|
||||
var disallowedUploadFilesValue = builder.Config.GetSection($"{Constants.Configuration.ConfigContent}:{nameof(ContentSettings.DisallowedUploadFiles)}").Get<string[]>();
|
||||
|
||||
if (disallowedUploadedFileExtensionsValue is null && disallowedUploadFilesValue is not null)
|
||||
{
|
||||
settings.DisallowedUploadedFileExtensions = disallowedUploadFilesValue;
|
||||
}
|
||||
});
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user