Interface IMediaEditingService
Defines the Media Editing Service, which provides operations for creating, updating, deleting, and managing IMedia items through the editing API.
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public interface IMediaEditingService
Methods
View SourceCreateAsync(MediaCreateModel, Guid)
Creates a new media item.
Declaration
Task<Attempt<MediaCreateResult, ContentEditingOperationStatus>> CreateAsync(MediaCreateModel createModel, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaCreateModel | createModel | The MediaCreateModel containing the media data to create. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<MediaCreateResult, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the MediaCreateResult containing the created media and ContentEditingOperationStatus indicating the operation outcome. |
DeleteAsync(Guid, Guid)
Permanently deletes a media item.
Declaration
Task<Attempt<IMedia?, ContentEditingOperationStatus>> DeleteAsync(Guid key, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to delete. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IMedia, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the deleted IMedia item (if successful) and ContentEditingOperationStatus indicating the operation outcome. |
DeleteFromRecycleBinAsync(Guid, Guid)
Permanently deletes a media item from the recycle bin.
Declaration
Task<Attempt<IMedia?, ContentEditingOperationStatus>> DeleteFromRecycleBinAsync(Guid key, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to delete from the recycle bin. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IMedia, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the deleted IMedia item (if successful) and ContentEditingOperationStatus indicating the operation outcome. |
GetAsync(Guid)
Gets a media item by its unique identifier.
Declaration
Task<IMedia?> GetAsync(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to retrieve. |
Returns
| Type | Description |
|---|---|
| Task<IMedia> | A task that represents the asynchronous operation. The task result contains
the IMedia item if found; otherwise, |
MoveAsync(Guid, Guid?, Guid)
Moves a media item to a new parent location.
Declaration
Task<Attempt<IMedia?, ContentEditingOperationStatus>> MoveAsync(Guid key, Guid? parentKey, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to move. |
| Guid? | parentKey | The unique identifier of the new parent, or |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IMedia, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the moved IMedia item (if successful) and ContentEditingOperationStatus indicating the operation outcome. |
MoveToRecycleBinAsync(Guid, Guid)
Moves a media item to the recycle bin.
Declaration
Task<Attempt<IMedia?, ContentEditingOperationStatus>> MoveToRecycleBinAsync(Guid key, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to move to the recycle bin. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IMedia, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the moved IMedia item (if successful) and ContentEditingOperationStatus indicating the operation outcome. |
RestoreAsync(Guid, Guid?, Guid)
Restores a media item from the recycle bin to a specified parent location.
Declaration
Task<Attempt<IMedia?, ContentEditingOperationStatus>> RestoreAsync(Guid key, Guid? parentKey, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to restore. |
| Guid? | parentKey | The unique identifier of the parent to restore to, or |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<IMedia, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the restored IMedia item (if successful) and ContentEditingOperationStatus indicating the operation outcome. |
SortAsync(Guid?, IEnumerable<SortingModel>, Guid)
Sorts media items under a specified parent.
Declaration
Task<ContentEditingOperationStatus> SortAsync(Guid? parentKey, IEnumerable<SortingModel> sortingModels, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid? | parentKey | The unique identifier of the parent, or |
| IEnumerable<SortingModel> | sortingModels | The collection of SortingModel items defining the sort order. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<ContentEditingOperationStatus> | A task that represents the asynchronous operation. The task result contains a ContentEditingOperationStatus indicating the operation outcome. |
UpdateAsync(Guid, MediaUpdateModel, Guid)
Updates an existing media item.
Declaration
Task<Attempt<MediaUpdateResult, ContentEditingOperationStatus>> UpdateAsync(Guid key, MediaUpdateModel updateModel, Guid userKey)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to update. |
| MediaUpdateModel | updateModel | The MediaUpdateModel containing the updated media data. |
| Guid | userKey | The unique identifier of the user performing the operation. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<MediaUpdateResult, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the MediaUpdateResult containing the updated media and ContentEditingOperationStatus indicating the operation outcome. |
ValidateCreateAsync(MediaCreateModel)
Validates a media creation model without persisting it.
Declaration
Task<Attempt<ContentValidationResult, ContentEditingOperationStatus>> ValidateCreateAsync(MediaCreateModel createModel)
Parameters
| Type | Name | Description |
|---|---|---|
| MediaCreateModel | createModel | The MediaCreateModel containing the media data to validate. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<ContentValidationResult, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the ContentValidationResult and ContentEditingOperationStatus indicating the validation outcome. |
ValidateUpdateAsync(Guid, MediaUpdateModel)
Validates a media update model without persisting it.
Declaration
Task<Attempt<ContentValidationResult, ContentEditingOperationStatus>> ValidateUpdateAsync(Guid key, MediaUpdateModel updateModel)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | The unique identifier of the media item to validate the update for. |
| MediaUpdateModel | updateModel | The MediaUpdateModel containing the updated media data to validate. |
Returns
| Type | Description |
|---|---|
| Task<Attempt<ContentValidationResult, ContentEditingOperationStatus>> | A task that represents the asynchronous operation. The task result contains an Attempt<TResult, TStatus> with the ContentValidationResult and ContentEditingOperationStatus indicating the validation outcome. |