Amend accessibility modifiers on file upload property editor components to support extension (#19643)
* Logic of getting media path moved to separate method. * TemporaryFileUploadValidator marked as public * Typo fix.
This commit is contained in:
@@ -189,8 +189,7 @@ internal class FileUploadPropertyValueEditor : DataValueEditor
|
||||
}
|
||||
|
||||
// get the filepath
|
||||
// in case we are using the old path scheme, try to re-use numbers (bah...)
|
||||
var filepath = _mediaFileManager.GetMediaPath(file.FileName, contentKey, propertyTypeKey); // fs-relative path
|
||||
string filepath = GetMediaPath(file, dataTypeConfiguration, contentKey, propertyTypeKey);
|
||||
|
||||
using (Stream filestream = file.OpenReadStream())
|
||||
{
|
||||
@@ -201,9 +200,19 @@ internal class FileUploadPropertyValueEditor : DataValueEditor
|
||||
|
||||
// TODO: Here it would make sense to do the auto-fill properties stuff but the API doesn't allow us to do that right
|
||||
// since we'd need to be able to return values for other properties from these methods
|
||||
_mediaFileManager.FileSystem.AddFile(filepath, filestream, true); // must overwrite!
|
||||
_mediaFileManager.FileSystem.AddFile(filepath, filestream, overrideIfExists: true); // must overwrite!
|
||||
}
|
||||
|
||||
return filepath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides media path.
|
||||
/// </summary>
|
||||
/// <returns>File system relative path</returns>
|
||||
protected virtual string GetMediaPath(TemporaryFileModel file, object? dataTypeConfiguration, Guid contentKey, Guid propertyTypeKey)
|
||||
{
|
||||
// in case we are using the old path scheme, try to re-use numbers (bah...)
|
||||
return _mediaFileManager.GetMediaPath(file.FileName, contentKey, propertyTypeKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.Models.TemporaryFile;
|
||||
using Umbraco.Cms.Core.Models.Validation;
|
||||
@@ -6,20 +6,20 @@ using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.PropertyEditors;
|
||||
|
||||
internal class TemporaryFileUploadValidator : IValueValidator
|
||||
public class TemporaryFileUploadValidator : IValueValidator
|
||||
{
|
||||
private readonly GetContentSettings _getContentSettings;
|
||||
private readonly ParseTemporaryFileKey _parseTemporaryFileKey;
|
||||
private readonly GetTemporaryFileModel _getTemporaryFileModel;
|
||||
private readonly ValidateFileType? _validateFileType;
|
||||
|
||||
internal delegate ContentSettings GetContentSettings();
|
||||
public delegate ContentSettings GetContentSettings();
|
||||
|
||||
internal delegate Guid? ParseTemporaryFileKey(object? editorValue);
|
||||
public delegate Guid? ParseTemporaryFileKey(object? editorValue);
|
||||
|
||||
internal delegate TemporaryFileModel? GetTemporaryFileModel(Guid temporaryFileKey);
|
||||
public delegate TemporaryFileModel? GetTemporaryFileModel(Guid temporaryFileKey);
|
||||
|
||||
internal delegate bool ValidateFileType(string extension, object? dataTypeConfiguration);
|
||||
public delegate bool ValidateFileType(string extension, object? dataTypeConfiguration);
|
||||
|
||||
public TemporaryFileUploadValidator(
|
||||
GetContentSettings getContentSettings,
|
||||
|
||||
Reference in New Issue
Block a user