View Source
  
  
  
  
    Inheritance
      System.Object
      Microsoft.AspNetCore.Mvc.ControllerBase
      
      
      
      
      
      
      
   
  
  Assembly: Umbraco.Web.BackOffice.dll
  
  
    [Authorize(Policy = "SectionAccessMedia")]
public class MediaController : ContentControllerBase
   
  
  
  Constructors
  
  
    View Source
  
  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)
  
  
  Declaration
  
    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
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | ICultureDictionary | 
        cultureDictionary | 
         | 
      
      
        | Microsoft.Extensions.Logging.ILoggerFactory | 
        loggerFactory | 
         | 
      
      
        | IShortStringHelper | 
        shortStringHelper | 
         | 
      
      
        | IEventMessagesFactory | 
        eventMessages | 
         | 
      
      
        | ILocalizedTextService | 
        localizedTextService | 
         | 
      
      
        | Microsoft.Extensions.Options.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 | 
         | 
      
      
        | Microsoft.AspNetCore.Authorization.IAuthorizationService | 
        authorizationService | 
         | 
      
      
        | AppCaches | 
        appCaches | 
         | 
      
    
  
  
    View Source
  
  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)
  
  
  Declaration
  
    [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
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | ICultureDictionary | 
        cultureDictionary | 
         | 
      
      
        | Microsoft.Extensions.Logging.ILoggerFactory | 
        loggerFactory | 
         | 
      
      
        | IShortStringHelper | 
        shortStringHelper | 
         | 
      
      
        | IEventMessagesFactory | 
        eventMessages | 
         | 
      
      
        | ILocalizedTextService | 
        localizedTextService | 
         | 
      
      
        | Microsoft.Extensions.Options.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 | 
         | 
      
      
        | Microsoft.AspNetCore.Authorization.IAuthorizationService | 
        authorizationService | 
         | 
      
      
        | AppCaches | 
        appCaches | 
         | 
      
      
        | IFileStreamSecurityValidator | 
        streamSecurityValidator | 
         | 
      
    
  
  Properties
  
  
    View Source
  
  
  
  
  Declaration
  
    protected int[] UserStartNodes { get; }
   
  Property Value
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Int32[] | 
         | 
      
    
  
  Methods
  
  
    View Source
  
  
  Moves an item to the recycle bin, if it is already there then it will permanently delete it
 
  
  Declaration
  
    [Authorize(Policy = "MediaPermissionPathById")]
[HttpPost]
public IActionResult DeleteById(int id)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Int32 | 
        id | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.IActionResult | 
         | 
      
    
  
  
    View Source
  
  
  
  
  Declaration
  
    [HttpDelete]
[HttpPost]
public IActionResult EmptyRecycleBin()
   
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.IActionResult | 
         | 
      
    
  
  
    View Source
  
  
  Gets the media item by id
 
  
  Declaration
  
    [Authorize(Policy = "MediaPermissionPathById")]
public MediaItemDisplay? GetById(Guid id)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Guid | 
        id | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Nullable<MediaItemDisplay> | 
         | 
      
    
  
  
    View Source
  
  
  Gets the media item by id
 
  
  Declaration
  
    [Authorize(Policy = "MediaPermissionPathById")]
public MediaItemDisplay? GetById(int id)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Int32 | 
        id | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | System.Nullable<MediaItemDisplay> | 
         | 
      
    
  
  
    View Source
  
  
  Gets the media item by id
 
  
  Declaration
  
    [Authorize(Policy = "MediaPermissionPathById")]
public ActionResult<MediaItemDisplay?> GetById(Udi id)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Udi | 
        id | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.ActionResult<System.Nullable<MediaItemDisplay>> | 
         | 
      
    
  
  
    View Source
  
  
  Return media for the specified ids
 
  
  Declaration
  
    public IEnumerable<MediaItemDisplay?> GetByIds([FromQuery] int[] ids)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Int32[] | 
        ids | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | IEnumerable<System.Nullable<MediaItemDisplay>> | 
         | 
      
    
  
  
    View Source
  
  
  Returns a paged result of media items known to be of a "Folder" type
 
  
  Declaration
  
    public PagedResult<ContentItemBasic<ContentPropertyBasic>> GetChildFolders(int id, int pageNumber = 1, int pageSize = 1000)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Int32 | 
        id | 
         | 
      
      
        | System.Int32 | 
        pageNumber | 
         | 
      
      
        | System.Int32 | 
        pageSize | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | PagedResult<ContentItemBasic<ContentPropertyBasic>> | 
         | 
      
    
  
  
    View Source
  
  
  Returns the child media objects - using the entity GUID id
 
  
  Declaration
  
    public ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>> GetChildren(Guid id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = null, bool orderBySystemField = true, string filter = "")
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Guid | 
        id | 
         | 
      
      
        | System.Int32 | 
        pageNumber | 
         | 
      
      
        | System.Int32 | 
        pageSize | 
         | 
      
      
        | System.String | 
        orderBy | 
         | 
      
      
        | Direction | 
        orderDirection | 
         | 
      
      
        | System.Boolean | 
        orderBySystemField | 
         | 
      
      
        | System.String | 
        filter | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>> | 
         | 
      
    
  
  
    View Source
  
  
  Returns the child media objects - using the entity INT id
 
  
  Declaration
  
    public PagedResult<ContentItemBasic<ContentPropertyBasic>> GetChildren(int id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = null, bool orderBySystemField = true, string filter = "")
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.Int32 | 
        id | 
         | 
      
      
        | System.Int32 | 
        pageNumber | 
         | 
      
      
        | System.Int32 | 
        pageSize | 
         | 
      
      
        | System.String | 
        orderBy | 
         | 
      
      
        | Direction | 
        orderDirection | 
         | 
      
      
        | System.Boolean | 
        orderBySystemField | 
         | 
      
      
        | System.String | 
        filter | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | PagedResult<ContentItemBasic<ContentPropertyBasic>> | 
         | 
      
    
  
  
    View Source
  
  
  Returns the child media objects - using the entity UDI id
 
  
  Declaration
  
    public ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>> GetChildren(Udi id, int pageNumber = 0, int pageSize = 0, string orderBy = "SortOrder", Direction orderDirection = null, bool orderBySystemField = true, string filter = "")
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Udi | 
        id | 
         | 
      
      
        | System.Int32 | 
        pageNumber | 
         | 
      
      
        | System.Int32 | 
        pageSize | 
         | 
      
      
        | System.String | 
        orderBy | 
         | 
      
      
        | Direction | 
        orderDirection | 
         | 
      
      
        | System.Boolean | 
        orderBySystemField | 
         | 
      
      
        | System.String | 
        filter | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.ActionResult<PagedResult<ContentItemBasic<ContentPropertyBasic>>> | 
         | 
      
    
  
  
    View Source
  
  
  Gets an empty content item for the
 
  
  Declaration
  
    public ActionResult<MediaItemDisplay?> GetEmpty(string contentTypeAlias, int parentId)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.String | 
        contentTypeAlias | 
         | 
      
      
        | System.Int32 | 
        parentId | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.ActionResult<System.Nullable<MediaItemDisplay>> | 
         | 
      
    
  
  
    View Source
  
  
  Returns an item to be used to display the recycle bin for media
 
  
  Declaration
  
    public MediaItemDisplay GetRecycleBin()
   
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | MediaItemDisplay | 
         | 
      
    
  
  
    View Source
  
  
  Returns the root media objects
 
  
  Declaration
  
    public IEnumerable<ContentItemBasic<ContentPropertyBasic>> GetRootMedia()
   
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | IEnumerable<ContentItemBasic<ContentPropertyBasic>> | 
         | 
      
    
  
  
    View Source
  
  PostAddFile(String, String, String, List<IFormFile>)
  Used to submit a media file
 
  
  Declaration
  
    public async Task<IActionResult> PostAddFile([FromForm] string path, [FromForm] string currentFolder, [FromForm] string contentTypeAlias, List<IFormFile> file)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | System.String | 
        path | 
         | 
      
      
        | System.String | 
        currentFolder | 
         | 
      
      
        | System.String | 
        contentTypeAlias | 
         | 
      
      
        | List<Microsoft.AspNetCore.Http.IFormFile> | 
        file | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Task<Microsoft.AspNetCore.Mvc.IActionResult> | 
         | 
      
    
  
  
  
  
    View Source
  
  PostAddFolder(PostedFolder)
  
  
  Declaration
  
    public async Task<ActionResult<MediaItemDisplay?>> PostAddFolder(PostedFolder folder)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | PostedFolder | 
        folder | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Task<Microsoft.AspNetCore.Mvc.ActionResult<System.Nullable<MediaItemDisplay>>> | 
         | 
      
    
  
  
    View Source
  
  PostMove(MoveOrCopy)
  Change the sort order for media
 
  
  Declaration
  
    public async Task<IActionResult> PostMove(MoveOrCopy move)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | MoveOrCopy | 
        move | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Task<Microsoft.AspNetCore.Mvc.IActionResult> | 
         | 
      
    
  
  
    View Source
  
  PostSave(MediaItemSave)
  
  
  Declaration
  
    [FileUploadCleanupFilter(true)]
public ActionResult<MediaItemDisplay?> PostSave([ModelBinder(typeof(MediaItemBinder))] MediaItemSave contentItem)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | MediaItemSave | 
        contentItem | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Microsoft.AspNetCore.Mvc.ActionResult<System.Nullable<MediaItemDisplay>> | 
         | 
      
    
  
  
    View Source
  
  PostSort(ContentSortOrder)
  Change the sort order for media
 
  
  Declaration
  
    public async Task<IActionResult> PostSort(ContentSortOrder sorted)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | ContentSortOrder | 
        sorted | 
         | 
      
    
  
  Returns
  
    
      
        | Type | 
        Description | 
      
    
    
      
        | Task<Microsoft.AspNetCore.Mvc.IActionResult> | 
         |