Class MediaController
- Namespace
- Umbraco.Cms.Web.BackOffice.Controllers
- Assembly
- Umbraco.Web.BackOffice.dll
[Authorize(Policy = "SectionAccessMedia")]
public class MediaController : ContentControllerBase
- Inheritance
-
MediaController
- Inherited Members
Remarks
This controller is decorated with the UmbracoApplicationAuthorizeAttribute which means that any user requesting access to ALL of the methods on this controller will need access to the media application.
Constructors
MediaController(ICultureDictionary, ILoggerFactory, IShortStringHelper, IEventMessagesFactory, ILocalizedTextService, IOptionsSnapshot<ContentSettings>, IMediaTypeService, IMediaService, IEntityService, IBackOfficeSecurityAccessor, IUmbracoMapper, IDataTypeService, ISqlContext, IContentTypeBaseServiceProvider, IRelationService, PropertyEditorCollection, MediaFileManager, MediaUrlGeneratorCollection, IHostingEnvironment, IImageUrlGenerator, IJsonSerializer, IAuthorizationService, AppCaches)
[Obsolete("Use constructor overload that has fileStreamSecurityValidator, scheduled for removal in v14")]
public MediaController(ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, IOptionsSnapshot<ContentSettings> contentSettings, IMediaTypeService mediaTypeService, IMediaService mediaService, IEntityService entityService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUmbracoMapper umbracoMapper, IDataTypeService dataTypeService, ISqlContext sqlContext, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IRelationService relationService, PropertyEditorCollection propertyEditors, MediaFileManager mediaFileManager, MediaUrlGeneratorCollection mediaUrlGenerators, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IJsonSerializer serializer, IAuthorizationService authorizationService, AppCaches appCaches)
Parameters
cultureDictionaryICultureDictionaryloggerFactoryILoggerFactoryshortStringHelperIShortStringHelpereventMessagesIEventMessagesFactorylocalizedTextServiceILocalizedTextServicecontentSettingsIOptionsSnapshot<ContentSettings>mediaTypeServiceIMediaTypeServicemediaServiceIMediaServiceentityServiceIEntityServicebackofficeSecurityAccessorIBackOfficeSecurityAccessorumbracoMapperIUmbracoMapperdataTypeServiceIDataTypeServicesqlContextISqlContextcontentTypeBaseServiceProviderIContentTypeBaseServiceProviderrelationServiceIRelationServicepropertyEditorsPropertyEditorCollectionmediaFileManagerMediaFileManagermediaUrlGeneratorsMediaUrlGeneratorCollectionhostingEnvironmentIHostingEnvironmentimageUrlGeneratorIImageUrlGeneratorserializerIJsonSerializerauthorizationServiceIAuthorizationServiceappCachesAppCaches
MediaController(ICultureDictionary, ILoggerFactory, IShortStringHelper, IEventMessagesFactory, ILocalizedTextService, IOptionsSnapshot<ContentSettings>, IMediaTypeService, IMediaService, IEntityService, IBackOfficeSecurityAccessor, IUmbracoMapper, IDataTypeService, ISqlContext, IContentTypeBaseServiceProvider, IRelationService, PropertyEditorCollection, MediaFileManager, MediaUrlGeneratorCollection, IHostingEnvironment, IImageUrlGenerator, IJsonSerializer, IAuthorizationService, AppCaches, IFileStreamSecurityValidator)
[ActivatorUtilitiesConstructor]
public MediaController(ICultureDictionary cultureDictionary, ILoggerFactory loggerFactory, IShortStringHelper shortStringHelper, IEventMessagesFactory eventMessages, ILocalizedTextService localizedTextService, IOptionsSnapshot<ContentSettings> contentSettings, IMediaTypeService mediaTypeService, IMediaService mediaService, IEntityService entityService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, IUmbracoMapper umbracoMapper, IDataTypeService dataTypeService, ISqlContext sqlContext, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, IRelationService relationService, PropertyEditorCollection propertyEditors, MediaFileManager mediaFileManager, MediaUrlGeneratorCollection mediaUrlGenerators, IHostingEnvironment hostingEnvironment, IImageUrlGenerator imageUrlGenerator, IJsonSerializer serializer, IAuthorizationService authorizationService, AppCaches appCaches, IFileStreamSecurityValidator streamSecurityValidator)
Parameters
cultureDictionaryICultureDictionaryloggerFactoryILoggerFactoryshortStringHelperIShortStringHelpereventMessagesIEventMessagesFactorylocalizedTextServiceILocalizedTextServicecontentSettingsIOptionsSnapshot<ContentSettings>mediaTypeServiceIMediaTypeServicemediaServiceIMediaServiceentityServiceIEntityServicebackofficeSecurityAccessorIBackOfficeSecurityAccessorumbracoMapperIUmbracoMapperdataTypeServiceIDataTypeServicesqlContextISqlContextcontentTypeBaseServiceProviderIContentTypeBaseServiceProviderrelationServiceIRelationServicepropertyEditorsPropertyEditorCollectionmediaFileManagerMediaFileManagermediaUrlGeneratorsMediaUrlGeneratorCollectionhostingEnvironmentIHostingEnvironmentimageUrlGeneratorIImageUrlGeneratorserializerIJsonSerializerauthorizationServiceIAuthorizationServiceappCachesAppCachesstreamSecurityValidatorIFileStreamSecurityValidator
Properties
UserStartNodes
protected int[] UserStartNodes { get; }
Property Value
- int[]
Methods
DeleteById(int)
Moves an item to the recycle bin, if it is already there then it will permanently delete it
[Authorize(Policy = "MediaPermissionPathById")]
[HttpPost]
public IActionResult DeleteById(int id)
Parameters
idint
Returns
EmptyRecycleBin()
Empties the recycle bin
[HttpDelete]
[HttpPost]
public IActionResult EmptyRecycleBin()
Returns
GetById(Guid)
Gets the media item by id
[Authorize(Policy = "MediaPermissionPathById")]
public MediaItemDisplay? GetById(Guid id)
Parameters
idGuid
Returns
- MediaItemDisplay
GetById(int)
Gets the media item by id
[Authorize(Policy = "MediaPermissionPathById")]
public MediaItemDisplay? GetById(int id)
Parameters
idint
Returns
- MediaItemDisplay
GetById(Udi)
Gets the media item by id
[Authorize(Policy = "MediaPermissionPathById")]
public ActionResult<MediaItemDisplay?> GetById(Udi id)
Parameters
idUdi
Returns
- ActionResult<MediaItemDisplay>
GetByIds(int[])
Return media for the specified ids
public IEnumerable<MediaItemDisplay?> GetByIds(int[] ids)
Parameters
idsint[]
Returns
- IEnumerable<MediaItemDisplay>
GetChildFolders(int, int, int)
Returns a paged result of media items known to be of a "Folder" type
public PagedResult<ContentItemBasic<ContentPropertyBasic>> GetChildFolders(int id, int pageNumber = 1, int pageSize = 1000)
Parameters
Returns
- PagedResult<ContentItemBasic<ContentPropertyBasic>>
GetChildren(Guid, int, int, string, Direction, bool, string)
Returns the child media objects - using the entity GUID id
public ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>> GetChildren(Guid id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = 0, bool orderBySystemField = true, string filter = "")
Parameters
idGuidpageNumberintpageSizeintorderBystringorderDirectionDirectionorderBySystemFieldboolfilterstring
Returns
- ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>>
GetChildren(int, int, int, string, Direction, bool, string)
Returns the child media objects - using the entity INT id
public PagedResult<ContentItemBasic<ContentPropertyBasic>> GetChildren(int id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = 0, bool orderBySystemField = true, string filter = "")
Parameters
idintpageNumberintpageSizeintorderBystringorderDirectionDirectionorderBySystemFieldboolfilterstring
Returns
- PagedResult<ContentItemBasic<ContentPropertyBasic>>
GetChildren(Udi, int, int, string, Direction, bool, string)
Returns the child media objects - using the entity UDI id
public ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>> GetChildren(Udi id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = 0, bool orderBySystemField = true, string filter = "")
Parameters
idUdipageNumberintpageSizeintorderBystringorderDirectionDirectionorderBySystemFieldboolfilterstring
Returns
- ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>>
GetEmpty(string, int)
Gets an empty content item for the
public ActionResult<MediaItemDisplay?> GetEmpty(string contentTypeAlias, int parentId)
Parameters
Returns
- ActionResult<MediaItemDisplay>
GetRecycleBin()
Returns an item to be used to display the recycle bin for media
public MediaItemDisplay GetRecycleBin()
Returns
- MediaItemDisplay
GetRootMedia()
Returns the root media objects
public IEnumerable<ContentItemBasic<ContentPropertyBasic>> GetRootMedia()
Returns
- IEnumerable<ContentItemBasic<ContentPropertyBasic>>
PostAddFile(string, string, string, List<IFormFile>)
Used to submit a media file
public Task<IActionResult> PostAddFile(string path, string currentFolder, string contentTypeAlias, List<IFormFile> file)
Parameters
Returns
Remarks
We cannot validate this request with attributes (nicely) due to the nature of the multi-part for data.
PostAddFolder(PostedFolder)
public Task<ActionResult<MediaItemDisplay?>> PostAddFolder(PostedFolder folder)
Parameters
folderPostedFolder
Returns
- Task<ActionResult<MediaItemDisplay>>
PostMove(MoveOrCopy)
Change the sort order for media
public Task<IActionResult> PostMove(MoveOrCopy move)
Parameters
moveMoveOrCopy
Returns
PostSave(MediaItemSave)
Saves content
[FileUploadCleanupFilter(true)]
public ActionResult<MediaItemDisplay?>? PostSave(MediaItemSave contentItem)
Parameters
contentItemMediaItemSave
Returns
- ActionResult<MediaItemDisplay>
PostSort(ContentSortOrder)
Change the sort order for media
public Task<IActionResult> PostSort(ContentSortOrder sorted)
Parameters
sortedContentSortOrder