Class MediaService
Represents the Media Service, which is an easy access to operations involving IMedia
Namespace: Umbraco.Cms.Core.Services
Assembly: Umbraco.Core.dll
Syntax
public class MediaService : RepositoryService, IMediaService, IContentServiceBase<IMedia>, IContentServiceBase, IService
Constructors
View SourceMediaService(ICoreScopeProvider, MediaFileManager, ILoggerFactory, IEventMessagesFactory, IMediaRepository, IAuditRepository, IMediaTypeRepository, IEntityRepository, IShortStringHelper, IUserIdKeyResolver)
Declaration
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 18.")]
public MediaService(ICoreScopeProvider provider, MediaFileManager mediaFileManager, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IMediaRepository mediaRepository, IAuditRepository auditRepository, IMediaTypeRepository mediaTypeRepository, IEntityRepository entityRepository, IShortStringHelper shortStringHelper, IUserIdKeyResolver userIdKeyResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | |
| MediaFileManager | mediaFileManager | |
| ILoggerFactory | loggerFactory | |
| IEventMessagesFactory | eventMessagesFactory | |
| IMediaRepository | mediaRepository | |
| IAuditRepository | auditRepository | |
| IMediaTypeRepository | mediaTypeRepository | |
| IEntityRepository | entityRepository | |
| IShortStringHelper | shortStringHelper | |
| IUserIdKeyResolver | userIdKeyResolver |
MediaService(ICoreScopeProvider, MediaFileManager, ILoggerFactory, IEventMessagesFactory, IMediaRepository, IAuditService, IAuditRepository, IMediaTypeRepository, IEntityRepository, IShortStringHelper, IUserIdKeyResolver)
Initializes a new instance of the MediaService class.
Declaration
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 18.")]
public MediaService(ICoreScopeProvider provider, MediaFileManager mediaFileManager, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IMediaRepository mediaRepository, IAuditService auditService, IAuditRepository auditRepository, IMediaTypeRepository mediaTypeRepository, IEntityRepository entityRepository, IShortStringHelper shortStringHelper, IUserIdKeyResolver userIdKeyResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The ICoreScopeProvider for database scope management. |
| MediaFileManager | mediaFileManager | The MediaFileManager for media file operations. |
| ILoggerFactory | loggerFactory | The Microsoft.Extensions.Logging.ILoggerFactory for creating loggers. |
| IEventMessagesFactory | eventMessagesFactory | The IEventMessagesFactory for creating event messages. |
| IMediaRepository | mediaRepository | The IMediaRepository for media persistence. |
| IAuditService | auditService | The IAuditService for audit logging. |
| IAuditRepository | auditRepository | The audit repository (obsolete, not used). |
| IMediaTypeRepository | mediaTypeRepository | The IMediaTypeRepository for media type persistence. |
| IEntityRepository | entityRepository | The IEntityRepository for entity operations. |
| IShortStringHelper | shortStringHelper | The IShortStringHelper for string operations. |
| IUserIdKeyResolver | userIdKeyResolver | The IUserIdKeyResolver for resolving user IDs. |
MediaService(ICoreScopeProvider, MediaFileManager, ILoggerFactory, IEventMessagesFactory, IMediaRepository, IAuditService, IAuditRepository, IMediaTypeRepository, IEntityRepository, IShortStringHelper, IUserIdKeyResolver, IMediaPathScheme, ILogger<MediaService>)
Initializes a new instance of the MediaService class.
Declaration
public MediaService(ICoreScopeProvider provider, MediaFileManager mediaFileManager, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IMediaRepository mediaRepository, IAuditService auditService, IAuditRepository auditRepository, IMediaTypeRepository mediaTypeRepository, IEntityRepository entityRepository, IShortStringHelper shortStringHelper, IUserIdKeyResolver userIdKeyResolver, IMediaPathScheme mediaPathScheme, ILogger<MediaService> logger)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The ICoreScopeProvider for database scope management. |
| MediaFileManager | mediaFileManager | The MediaFileManager for media file operations. |
| ILoggerFactory | loggerFactory | The Microsoft.Extensions.Logging.ILoggerFactory for creating loggers. |
| IEventMessagesFactory | eventMessagesFactory | The IEventMessagesFactory for creating event messages. |
| IMediaRepository | mediaRepository | The IMediaRepository for media persistence. |
| IAuditService | auditService | The IAuditService for audit logging. |
| IAuditRepository | auditRepository | |
| IMediaTypeRepository | mediaTypeRepository | The IMediaTypeRepository for media type persistence. |
| IEntityRepository | entityRepository | The IEntityRepository for entity operations. |
| IShortStringHelper | shortStringHelper | The IShortStringHelper for string operations. |
| IUserIdKeyResolver | userIdKeyResolver | The IUserIdKeyResolver for resolving user IDs. |
| IMediaPathScheme | mediaPathScheme | |
| ILogger<MediaService> | logger |
MediaService(ICoreScopeProvider, MediaFileManager, ILoggerFactory, IEventMessagesFactory, IMediaRepository, IAuditService, IMediaTypeRepository, IEntityRepository, IShortStringHelper, IUserIdKeyResolver)
Initializes a new instance of the MediaService class.
Declaration
[Obsolete("Please use the non-obsolete constructor. Scheduled for removal in Umbraco 18.")]
public MediaService(ICoreScopeProvider provider, MediaFileManager mediaFileManager, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IMediaRepository mediaRepository, IAuditService auditService, IMediaTypeRepository mediaTypeRepository, IEntityRepository entityRepository, IShortStringHelper shortStringHelper, IUserIdKeyResolver userIdKeyResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| ICoreScopeProvider | provider | The ICoreScopeProvider for database scope management. |
| MediaFileManager | mediaFileManager | The MediaFileManager for media file operations. |
| ILoggerFactory | loggerFactory | The Microsoft.Extensions.Logging.ILoggerFactory for creating loggers. |
| IEventMessagesFactory | eventMessagesFactory | The IEventMessagesFactory for creating event messages. |
| IMediaRepository | mediaRepository | The IMediaRepository for media persistence. |
| IAuditService | auditService | |
| IMediaTypeRepository | mediaTypeRepository | The IMediaTypeRepository for media type persistence. |
| IEntityRepository | entityRepository | The IEntityRepository for entity operations. |
| IShortStringHelper | shortStringHelper | The IShortStringHelper for string operations. |
| IUserIdKeyResolver | userIdKeyResolver | The IUserIdKeyResolver for resolving user IDs. |
Methods
View SourceCheckDataIntegrity(ContentDataIntegrityReportOptions)
Checks the data integrity of the media tree and optionally fixes detected issues.
Declaration
public ContentDataIntegrityReport CheckDataIntegrity(ContentDataIntegrityReportOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentDataIntegrityReportOptions | options | The options specifying how to check and fix data integrity. |
Returns
| Type | Description |
|---|---|
| ContentDataIntegrityReport | A ContentDataIntegrityReport containing details of any detected and fixed issues. |
Count(string?)
Counts the total number of media items, optionally filtered by media type alias.
Declaration
public int Count(string? mediaTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mediaTypeAlias | Optional alias of the IMediaType to filter by. |
Returns
| Type | Description |
|---|---|
| int | The total count of media items matching the criteria. |
CountChildren(int, string?)
Counts the number of direct children of a media item, optionally filtered by media type alias.
Declaration
public int CountChildren(int parentId, string? mediaTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The identifier of the parent media item. |
| string | mediaTypeAlias | Optional alias of the IMediaType to filter by. |
Returns
| Type | Description |
|---|---|
| int | The count of direct children matching the criteria. |
CountDescendants(int, string?)
Counts all descendants of a media item, optionally filtered by media type alias.
Declaration
public int CountDescendants(int parentId, string? mediaTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parentId | The identifier of the parent media item. |
| string | mediaTypeAlias | Optional alias of the IMediaType to filter by. |
Returns
| Type | Description |
|---|---|
| int | The count of all descendants matching the criteria. |
CountNotTrashed(string?)
Counts the total number of media items that are not in the recycle bin, optionally filtered by media type alias.
Declaration
public int CountNotTrashed(string? mediaTypeAlias = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mediaTypeAlias | Optional alias of the IMediaType to filter by. |
Returns
| Type | Description |
|---|---|
| int | The total count of non-trashed media items matching the criteria. |
CreateMedia(string, Guid, string, int)
Creates an IMedia object using the alias of the IMediaType that this Media should based on.
Declaration
public IMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Name of the Media object |
| Guid | parentId | Id of Parent for the new Media item |
| string | mediaTypeAlias | Alias of the IMediaType |
| int | userId | Optional id of the user creating the media item |
Returns
| Type | Description |
|---|---|
| IMedia |
Remarks
Note that using this method will simply return a new IMedia without any identity as it has not yet been persisted. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMedia(string?, int, string, int)
Creates an IMedia object of a specified media type.
Declaration
public IMedia CreateMedia(string? name, int parentId, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the media object. |
| int | parentId | The identifier of the parent, or -1. |
| string | mediaTypeAlias | The alias of the media type. |
| int | userId | The optional id of the user creating the media. |
Returns
| Type | Description |
|---|---|
| IMedia | The media object. |
Remarks
This method simply returns a new, non-persisted, IMedia without any identity. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMedia(string, string, int)
Creates an IMedia object of a specified media type, at root.
Declaration
public IMedia CreateMedia(string name, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the media object. |
| string | mediaTypeAlias | The alias of the media type. |
| int | userId | The optional id of the user creating the media. |
Returns
| Type | Description |
|---|---|
| IMedia | The media object. |
Remarks
This method simply returns a new, non-persisted, IMedia without any identity. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMedia(string, IMedia?, string, int)
Creates an IMedia object of a specified media type, under a parent.
Declaration
public IMedia CreateMedia(string name, IMedia? parent, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the media object. |
| IMedia | parent | The parent media object. |
| string | mediaTypeAlias | The alias of the media type. |
| int | userId | The optional id of the user creating the media. |
Returns
| Type | Description |
|---|---|
| IMedia | The media object. |
Remarks
This method simply returns a new, non-persisted, IMedia without any identity. It is intended as a shortcut to creating new media objects that does not invoke a save operation against the database.
CreateMediaWithIdentity(string, int, string, int)
Creates an IMedia object of a specified media type.
Declaration
public IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the media object. |
| int | parentId | The identifier of the parent, or -1. |
| string | mediaTypeAlias | The alias of the media type. |
| int | userId | The optional id of the user creating the media. |
Returns
| Type | Description |
|---|---|
| IMedia | The media object. |
Remarks
This method returns a new, persisted, IMedia with an identity.
CreateMediaWithIdentity(string, IMedia, string, int)
Creates an IMedia object of a specified media type, under a parent.
Declaration
public IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the media object. |
| IMedia | parent | The parent media object. |
| string | mediaTypeAlias | The alias of the media type. |
| int | userId | The optional id of the user creating the media. |
Returns
| Type | Description |
|---|---|
| IMedia | The media object. |
Remarks
This method returns a new, persisted, IMedia with an identity.
Delete(IMedia, int)
Permanently deletes an IMedia object
Declaration
public Attempt<OperationResult?> Delete(IMedia media, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | The IMedia to delete |
| int | userId | Id of the User deleting the Media |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> |
DeleteMediaFile(string)
Deletes a media file from storage.
Declaration
public void DeleteMediaFile(string filepath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filepath | The path of the file to delete. |
DeleteMediaOfType(int, int)
Deletes all media of specified type. All children of deleted media is moved to Recycle Bin.
Declaration
public void DeleteMediaOfType(int mediaTypeId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | mediaTypeId | Id of the IMediaType |
| int | userId | Optional id of the user deleting the media |
Remarks
This needs extra care and attention as its potentially a dangerous and extensive operation
DeleteMediaOfTypes(IEnumerable<int>, int)
Deletes all media of specified type. All children of deleted media is moved to Recycle Bin.
Declaration
public void DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | mediaTypeIds | Id of the IMediaType |
| int | userId | Optional id of the user deleting the media |
Remarks
This needs extra care and attention as its potentially a dangerous and extensive operation.
Deletes media items of the specified type, and only that type. Does *not* handle content types inheritance and compositions, which need to be managed outside of this method.
DeleteVersion(int, int, bool, int)
Permanently deletes specific version(s) from an IMedia object. This method will never delete the latest version of a media item.
Declaration
public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IMedia object to delete a version from |
| int | versionId | Id of the version to delete |
| bool | deletePriorVersions | Boolean indicating whether to delete versions prior to the versionId |
| int | userId | Optional Id of the User deleting versions of a Media object |
DeleteVersions(int, DateTime, int)
Permanently deletes versions from an IMedia object prior to a specific date. This method will never delete the latest version of a media item.
Declaration
public void DeleteVersions(int id, DateTime versionDate, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IMedia object to delete versions from |
| DateTime | versionDate | Latest version date |
| int | userId | Optional Id of the User deleting versions of a Media object |
EmptyRecycleBin(int)
Empties the Recycle Bin by deleting all IMedia that resides in the bin
Declaration
public OperationResult EmptyRecycleBin(int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| int | userId | Optional Id of the User emptying the Recycle Bin |
Returns
| Type | Description |
|---|---|
| OperationResult |
EmptyRecycleBinAsync(Guid)
Empties the Recycle Bin by deleting all IMedia items that reside in the bin.
Declaration
public Task<OperationResult> EmptyRecycleBinAsync(Guid userId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | userId | The unique identifier of the user emptying the Recycle Bin. |
Returns
| Type | Description |
|---|---|
| Task<OperationResult> | A task that represents the asynchronous operation. The task result contains an OperationResult indicating the outcome. |
GetAncestors(int)
Gets a collection of IMedia objects, which are ancestors of the current media.
Declaration
public IEnumerable<IMedia> GetAncestors(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IMedia to retrieve ancestors for |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetAncestors(IMedia?)
Gets a collection of IMedia objects, which are ancestors of the current media.
Declaration
public IEnumerable<IMedia> GetAncestors(IMedia? media)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | IMedia to retrieve ancestors for |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetById(Guid)
Gets an IMedia object by its 'UniqueId'
Declaration
public IMedia? GetById(Guid key)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | key | Guid key of the Media to retrieve |
Returns
| Type | Description |
|---|---|
| IMedia |
GetById(int)
Gets an IMedia object by Id
Declaration
public IMedia? GetById(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the Media to retrieve |
Returns
| Type | Description |
|---|---|
| IMedia |
GetByIds(IEnumerable<Guid>)
Gets an IMedia object by Id
Declaration
public IEnumerable<IMedia> GetByIds(IEnumerable<Guid> ids)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Guid> | ids | Ids of the Media to retrieve |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> |
GetByIds(IEnumerable<int>)
Gets an IMedia object by Id
Declaration
public IEnumerable<IMedia> GetByIds(IEnumerable<int> ids)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<int> | ids | Ids of the Media to retrieve |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> |
GetByLevel(int)
Gets a collection of IMedia objects by Level
Declaration
public IEnumerable<IMedia> GetByLevel(int level)
Parameters
| Type | Name | Description |
|---|---|---|
| int | level | The level to retrieve Media from |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IMedia objects |
Remarks
Contrary to most methods, this method filters out trashed media items.
GetMediaByPath(string)
Gets an IMedia object from the path stored in the 'umbracoFile' property.
Declaration
public IMedia? GetMediaByPath(string mediaPath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | mediaPath | Path of the media item to retrieve (for example: /media/1024/koala_403x328.jpg) |
Returns
| Type | Description |
|---|---|
| IMedia |
GetMediaFileContentStream(string)
Gets a stream containing the content of a media file.
Declaration
public Stream GetMediaFileContentStream(string filepath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filepath | The path to the media file. |
Returns
| Type | Description |
|---|---|
| Stream | A System.IO.Stream containing the file content, or System.IO.Stream.Null if the file does not exist or cannot be opened. |
GetMediaFileSize(string)
Gets the size of a media file in bytes.
Declaration
public long GetMediaFileSize(string filepath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filepath | The path to the media file. |
Returns
| Type | Description |
|---|---|
| long | The size of the file in bytes. |
GetPagedChildren(int, long, int, out long, IQuery<IMedia>?, Ordering?)
Gets a collection of IMedia objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedChildren(int id, long pageIndex, int pageSize, out long totalChildren, IQuery<IMedia>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the Parent to retrieve Children from |
| long | pageIndex | Page number |
| int | pageSize | Page size |
| long | totalChildren | |
| IQuery<IMedia> | filter | |
| Ordering | ordering |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedDescendants(int, long, int, out long, IQuery<IMedia>?, Ordering?)
Gets a collection of IMedia objects by Parent Id
Declaration
public IEnumerable<IMedia> GetPagedDescendants(int id, long pageIndex, int pageSize, out long totalChildren, IQuery<IMedia>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the Parent to retrieve Descendants from |
| long | pageIndex | Page number |
| int | pageSize | Page size |
| long | totalChildren | |
| IQuery<IMedia> | filter | |
| Ordering | ordering |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IContent objects |
GetPagedMediaInRecycleBin(long, int, out long, IQuery<IMedia>?, Ordering?)
Gets a collection of an IMedia objects, which resides in the Recycle Bin
Declaration
public IEnumerable<IMedia> GetPagedMediaInRecycleBin(long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| long | pageIndex | |
| int | pageSize | |
| long | totalRecords | |
| IQuery<IMedia> | filter | |
| Ordering | ordering |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetPagedOfType(int, long, int, out long, IQuery<IMedia>?, Ordering?)
Gets paged documents of a content
Declaration
public IEnumerable<IMedia> GetPagedOfType(int contentTypeId, long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int | contentTypeId | The page number. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| IQuery<IMedia> | filter | Search text filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> |
GetPagedOfTypes(int[], long, int, out long, IQuery<IMedia>?, Ordering?)
Gets paged documents for specified content types
Declaration
public IEnumerable<IMedia> GetPagedOfTypes(int[] contentTypeIds, long pageIndex, int pageSize, out long totalRecords, IQuery<IMedia>? filter = null, Ordering? ordering = null)
Parameters
| Type | Name | Description |
|---|---|---|
| int[] | contentTypeIds | The page number. |
| long | pageIndex | The page number. |
| int | pageSize | The page size. |
| long | totalRecords | Total number of documents. |
| IQuery<IMedia> | filter | Search text filter. |
| Ordering | ordering | Ordering infos. |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> |
GetParent(int)
Gets the parent of the current media as an IMedia item.
Declaration
public IMedia? GetParent(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IMedia to retrieve the parent from |
Returns
| Type | Description |
|---|---|
| IMedia | Parent IMedia object |
GetParent(IMedia?)
Gets the parent of the current media as an IMedia item.
Declaration
public IMedia? GetParent(IMedia? media)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | IMedia to retrieve the parent from |
Returns
| Type | Description |
|---|---|
| IMedia | Parent IMedia object |
GetRootMedia()
Gets a collection of IMedia objects, which reside at the first level / root
Declaration
public IEnumerable<IMedia> GetRootMedia()
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IMedia objects |
GetVersion(int)
Gets a specific version of an IMedia item.
Declaration
public IMedia? GetVersion(int versionId)
Parameters
| Type | Name | Description |
|---|---|---|
| int | versionId | Id of the version to retrieve |
Returns
| Type | Description |
|---|---|
| IMedia | An IMedia item |
GetVersions(int)
Gets a collection of an IMedia objects versions by Id
Declaration
public IEnumerable<IMedia> GetVersions(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id |
Returns
| Type | Description |
|---|---|
| IEnumerable<IMedia> | An Enumerable list of IMedia objects |
HasChildren(int)
Checks whether an IMedia item has any children
Declaration
public bool HasChildren(int id)
Parameters
| Type | Name | Description |
|---|---|---|
| int | id | Id of the IMedia |
Returns
| Type | Description |
|---|---|
| bool | True if the media has any children otherwise False |
Move(IMedia, int, int)
Moves an IMedia object to a new location
Declaration
public Attempt<OperationResult?> Move(IMedia media, int parentId, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | The IMedia to move |
| int | parentId | Id of the Media's new Parent |
| int | userId | Id of the User moving the Media |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> |
MoveToRecycleBin(IMedia, int)
Deletes an IMedia object by moving it to the Recycle Bin
Declaration
public Attempt<OperationResult?> MoveToRecycleBin(IMedia media, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | The IMedia to delete |
| int | userId | Id of the User deleting the Media |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> |
RecycleBinSmells()
Checks whether the Recycle Bin contains any media items.
Declaration
public bool RecycleBinSmells()
Returns
| Type | Description |
|---|---|
| bool |
|
Save(IEnumerable<IMedia>, int)
Saves a collection of IMedia objects
Declaration
public Attempt<OperationResult?> Save(IEnumerable<IMedia> medias, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IMedia> | medias | Collection of IMedia to save |
| int | userId | Id of the User saving the Media |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> |
Save(IMedia, int)
Saves a single IMedia object
Declaration
public Attempt<OperationResult?> Save(IMedia media, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IMedia | media | The IMedia to save |
| int | userId | Id of the User saving the Media |
Returns
| Type | Description |
|---|---|
| Attempt<OperationResult> |
SetMediaFileContent(string, Stream)
Sets the content of a media file.
Declaration
public void SetMediaFileContent(string filepath, Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filepath | The path where the file should be stored. |
| Stream | stream | A System.IO.Stream containing the file content to write. |
Sort(IEnumerable<IMedia>, int)
Sorts a collection of IMedia objects by updating the SortOrder according to the ordering of items in the passed in System.Collections.Generic.IEnumerable<T>.
Declaration
public bool Sort(IEnumerable<IMedia> items, int userId = -1)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<IMedia> | items | |
| int | userId |
Returns
| Type | Description |
|---|---|
| bool | True if sorting succeeded, otherwise False |