Files
Umbraco-CMS/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs
Nicklas Kramer 50ae48b0a2 V17 - Removed obsoleted code from Umbraco.Infrastructure (#19977)
* Removing obsoleted code from MigrationPlanExecutor.cs & Interface

* Removing obsoleted code from EmailAddressPropertyEditor.cs

* Removing obsoleted class CacheRebuilder.cs

* Removing obsoleted code from TextBuilder.cs

* Removing obsoleted class ICacheRebuilder.cs

* Removing obsoleted code from SerilogLogger.cs

* Removing the use of Infrastructure IBackgroundTaskQueue.cs and replacing usage with the Core replacement

* Removing obsoleted code from the FileUploadPropertyEditor.cs

* Removing obsoleted code from BlockValuePropertyValueEditorBase.cs

* Removing obsoleted constructors and methods from MultiNodeTreePickerPropertyEditor.cs and TextHeaderWriter.cs

* Removing obsoleted code from CacheInstructionService.cs

* Bumping obsoleted code from MigrationBase.cs to V18

* Removing obsoleted code from EmailSender.cs

* Removing obsoleted code from BlockEditorVarianceHandler.cs

* Removing obsoleted code from IBackOfficeApplicationManager.cs

* Removing obsoleted code from RedirectTracker.cs & RichTextEditorPastedImages.cs
2025-08-22 14:38:27 +02:00

58 lines
1.7 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Diagnostics.CodeAnalysis;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
namespace Umbraco.Cms.Core.PropertyEditors;
/// <summary>
/// Defines the file upload property editor.
/// </summary>
[DataEditor(
Constants.PropertyEditors.Aliases.UploadField,
ValueEditorIsReusable = true)]
public class FileUploadPropertyEditor : DataEditor, IMediaUrlGenerator
{
private readonly IIOHelper _ioHelper;
/// <summary>
/// Initializes a new instance of the <see cref="FileUploadPropertyEditor"/> class.
/// </summary>
public FileUploadPropertyEditor(
IDataValueEditorFactory dataValueEditorFactory,
IIOHelper ioHelper)
: base(dataValueEditorFactory)
{
_ioHelper = ioHelper;
SupportsReadOnly = true;
}
/// <inheritdoc/>
public bool TryGetMediaPath(string? propertyEditorAlias, object? value, [MaybeNullWhen(false)] out string mediaPath)
{
if (propertyEditorAlias == Alias &&
value?.ToString() is var mediaPathValue &&
!string.IsNullOrWhiteSpace(mediaPathValue))
{
mediaPath = mediaPathValue;
return true;
}
mediaPath = null;
return false;
}
/// <inheritdoc />
protected override IConfigurationEditor CreateConfigurationEditor() =>
new FileUploadConfigurationEditor(_ioHelper);
/// <summary>
/// Creates the corresponding property value editor.
/// </summary>
/// <returns>The corresponding property value editor.</returns>
protected override IDataValueEditor CreateValueEditor()
=> DataValueEditorFactory.Create<FileUploadPropertyValueEditor>(Attribute!);
}