Search Results for

    Show / Hide Table of Contents
    View Source

    Class MediaController

    Inheritance
    System.Object
    Microsoft.AspNetCore.Mvc.ControllerBase
    UmbracoApiControllerBase
    UmbracoApiController
    UmbracoAuthorizedApiController
    UmbracoAuthorizedJsonController
    BackOfficeNotificationsController
    ContentControllerBase
    Namespace: Umbraco.Cms.Web.BackOffice.Controllers
    Assembly: Umbraco.Web.BackOffice.dll
    Syntax
    [PluginController("UmbracoApi")]
    [Authorize(Policy = "SectionAccessMedia")]
    public class MediaController : ContentControllerBase, IUmbracoFeature, IDiscoverable
    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

    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

    UserStartNodes

    Declaration
    protected int[] UserStartNodes { get; }
    Property Value
    Type Description
    System.Int32[]

    Methods

    View Source

    DeleteById(Int32)

    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

    EmptyRecycleBin()

    Empties the recycle bin

    Declaration
    [HttpDelete]
    [HttpPost]
    public IActionResult EmptyRecycleBin()
    Returns
    Type Description
    Microsoft.AspNetCore.Mvc.IActionResult
    View Source

    GetById(Guid)

    Gets the media item by id

    Declaration
    [Authorize(Policy = "MediaPermissionPathById")]
    public MediaItemDisplay GetById(Guid id)
    Parameters
    Type Name Description
    Guid id
    Returns
    Type Description
    MediaItemDisplay
    View Source

    GetById(Int32)

    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
    MediaItemDisplay
    View Source

    GetById(Udi)

    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<MediaItemDisplay>
    View Source

    GetByIds(Int32[])

    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<MediaItemDisplay>
    View Source

    GetChildFolders(Int32, Int32, Int32)

    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

    GetChildren(Guid, Int32, Int32, String, Direction, Boolean, String)

    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 = Direction.Ascending, 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

    GetChildren(Int32, Int32, Int32, String, Direction, Boolean, String)

    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 = Direction.Ascending, 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

    GetChildren(Udi, Int32, Int32, String, Direction, Boolean, String)

    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 = Direction.Ascending, 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

    GetEmpty(String, Int32)

    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<MediaItemDisplay>
    View Source

    GetPagedReferences(Int32, String, Int32, Int32)

    Declaration
    public PagedResult<EntityBasic> GetPagedReferences(int id, string entityType, int pageNumber = 1, int pageSize = 100)
    Parameters
    Type Name Description
    System.Int32 id
    System.String entityType
    System.Int32 pageNumber
    System.Int32 pageSize
    Returns
    Type Description
    PagedResult<EntityBasic>
    View Source

    GetRecycleBin()

    Returns an item to be used to display the recycle bin for media

    Declaration
    public MediaItemDisplay GetRecycleBin()
    Returns
    Type Description
    MediaItemDisplay
    View Source

    GetRootMedia()

    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>
    Remarks

    We cannot validate this request with attributes (nicely) due to the nature of the multi-part for data.

    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<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)

    Saves content

    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<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>
    • Improve this Doc
    • View Source
    In This Article
    • 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)
      • 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)
    • Properties
      • UserStartNodes
    • Methods
      • DeleteById(Int32)
      • EmptyRecycleBin()
      • GetById(Guid)
      • GetById(Int32)
      • GetById(Udi)
      • GetByIds(Int32[])
      • GetChildFolders(Int32, Int32, Int32)
      • GetChildren(Guid, Int32, Int32, String, Direction, Boolean, String)
      • GetChildren(Int32, Int32, Int32, String, Direction, Boolean, String)
      • GetChildren(Udi, Int32, Int32, String, Direction, Boolean, String)
      • GetEmpty(String, Int32)
      • GetPagedReferences(Int32, String, Int32, Int32)
      • GetRecycleBin()
      • GetRootMedia()
      • PostAddFile(String, String, String, List<IFormFile>)
      • PostAddFolder(PostedFolder)
      • PostMove(MoveOrCopy)
      • PostSave(MediaItemSave)
      • PostSort(ContentSortOrder)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX