API Reference: FileUploadAttribute Class

The FileUploadAttribute can be applied to asset content models. The attribute specifies that assets of this model can be created through uploading files directly in an asset library.  This simplifies (bulk) creation of media assets in the back office. If this attribute is not set, assets of this model can only be created individually by selecting the "New" command in the back office user interface.

When files are uploaded in this way, the system only populates the file property of the asset content. If the model contains other properties that are required or have validation, the asset content may result in an invalid state. These properties will still need to be set by the content editor to valid values after the file upload has been completed. This can be mitigated by implementing and setting a custom IFileUploadHandler. The IFileUploadHandler.HandleFileUploadAsync() method gets called immediately after the file has been uploaded, but before the content has been saved. Within this method, you can populate any other content properties to default or computed values.

When using the FileUploadAttribute, it is recommended to either not have properties on the model that result in an invalid state, or set a custom IFileUploadHandler to populate content to a valid state. This may prevent errors caused by invalid content and reduce the need for content editors to go back and revise newly created assets.


Decorate the asset content model class with the FileUploadAttribute. The attribute is not inherited from base types.

Optionally set the FileUploadHandlerType property to a concrete class type implementing IFileUploadHandler to provide a custom file upload handler. If your custom file handler type is registered with the IoC container, Redakt will request it from the service provider. Otherwise, a new handler is instantiated.

A custom upload handler replaces the default upload handler, meaning you will also have to set the media file to the correct property yourself. If you do not specify a custom upload handler, the default handler will set the uploaded file to the primary media property of the model.


public class Image: IContentType
        [AcceptMediaType("image/jpeg", "image/gif", "image/png", "image/bmp", "image/tiff", "image/svg+xml")]
        public Media File { get; set; }

        public string AlternateText { get; set; }  // Not required so will not result in an invalid content state after upload.