Skip to content

Commit e0a00bf

Browse files
authored
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.
1 parent 914bc40 commit e0a00bf

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ private bool IsAllowedInDataTypeConfiguration(string extension, object? dataType
189189
}
190190

191191
// get the filepath
192-
// in case we are using the old path scheme, try to re-use numbers (bah...)
193-
var filepath = _mediaFileManager.GetMediaPath(file.FileName, contentKey, propertyTypeKey); // fs-relative path
192+
string filepath = GetMediaPath(file, dataTypeConfiguration, contentKey, propertyTypeKey);
194193

195194
using (Stream filestream = file.OpenReadStream())
196195
{
@@ -201,9 +200,19 @@ private bool IsAllowedInDataTypeConfiguration(string extension, object? dataType
201200

202201
// TODO: Here it would make sense to do the auto-fill properties stuff but the API doesn't allow us to do that right
203202
// since we'd need to be able to return values for other properties from these methods
204-
_mediaFileManager.FileSystem.AddFile(filepath, filestream, true); // must overwrite!
203+
_mediaFileManager.FileSystem.AddFile(filepath, filestream, overrideIfExists: true); // must overwrite!
205204
}
206205

207206
return filepath;
208207
}
208+
209+
/// <summary>
210+
/// Provides media path.
211+
/// </summary>
212+
/// <returns>File system relative path</returns>
213+
protected virtual string GetMediaPath(TemporaryFileModel file, object? dataTypeConfiguration, Guid contentKey, Guid propertyTypeKey)
214+
{
215+
// in case we are using the old path scheme, try to re-use numbers (bah...)
216+
return _mediaFileManager.GetMediaPath(file.FileName, contentKey, propertyTypeKey);
217+
}
209218
}

src/Umbraco.Infrastructure/PropertyEditors/TemporaryFileUploadValidator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22
using Umbraco.Cms.Core.Configuration.Models;
33
using Umbraco.Cms.Core.Models.TemporaryFile;
44
using Umbraco.Cms.Core.Models.Validation;
55
using Umbraco.Extensions;
66

77
namespace Umbraco.Cms.Core.PropertyEditors;
88

9-
internal class TemporaryFileUploadValidator : IValueValidator
9+
public class TemporaryFileUploadValidator : IValueValidator
1010
{
1111
private readonly GetContentSettings _getContentSettings;
1212
private readonly ParseTemporaryFileKey _parseTemporaryFileKey;
1313
private readonly GetTemporaryFileModel _getTemporaryFileModel;
1414
private readonly ValidateFileType? _validateFileType;
1515

16-
internal delegate ContentSettings GetContentSettings();
16+
public delegate ContentSettings GetContentSettings();
1717

18-
internal delegate Guid? ParseTemporaryFileKey(object? editorValue);
18+
public delegate Guid? ParseTemporaryFileKey(object? editorValue);
1919

20-
internal delegate TemporaryFileModel? GetTemporaryFileModel(Guid temporaryFileKey);
20+
public delegate TemporaryFileModel? GetTemporaryFileModel(Guid temporaryFileKey);
2121

22-
internal delegate bool ValidateFileType(string extension, object? dataTypeConfiguration);
22+
public delegate bool ValidateFileType(string extension, object? dataTypeConfiguration);
2323

2424
public TemporaryFileUploadValidator(
2525
GetContentSettings getContentSettings,

0 commit comments

Comments
 (0)