AssetFile

The AssetFile entity represents an actual video or audio file that is stored in a blob container. An asset file is always associated with an asset, and an asset may contain one or many files. The Media Services Encoder task fails if an asset file object is not associated with a digital file in a blob container.

This topic gives an overview of the AssetFile entity and also demonstrates how to execute various operations with the Media Services REST API.

Important

When accessing entities in Media Services, you must set specific header fields and values in your HTTP requests.
For more information, see Setup for Media Services REST API Development and Connecting to Media Services with the Media Services REST API.

AssetFile Entity Properties

Property Type Description
Id

Read-only. Set by Media Services at creation time.
Edm.String Unique identifier.
Name

Required.
Edm.String Friendly name for your AssetFile. The default value is the filename you used during your file upload. Maximum length is 260. Note: Media Services uses the value of the Name property when building URLs for the streaming content (for example, http://{AMSAccount}.origin.mediaservices.windows.net/{GUID}/{IAssetFile.Name}/streamingParameters.) For this reason, percent-encoding is not allowed. The value of the Name property cannot have any of the following percent-encoding-reserved characters: !*'();:@&=+$,/?%#[]". Also, there can only be one ‘.’ for the file name extension.
ContentFileSize

Optional.
Edm.Int64 AssetFile size (in bytes) of the content.
ParentAssetId

Required. Cannot be updated after the entity has been created.
Edm.String Asset Id of the Asset that this file is associated with.
EncryptionVersion

Optional.
Edm.String Current supported version for both StorageEncryption and CommonEncryption is "1.0"
EncryptionScheme

Optional.
Edm.String The encryption scheme used for this file. The valid values are: "StorageEncryption" or "CommonEncryption".
IsEncrypted

Optional.
Edm.Boolean This value should be set to true if this file is stored encrypted.
EncryptionKeyId

Optional.
Edm.String Encrypted ContentKey Id.
InitializationVector

Optional.
Edm.String The initialization vector used for storage encryption.
IsPrimary

Optional.
Edm.Boolean Determines if this file is the primary file in a multi-file Asset.
LastModified

Read-only. Set by Media Services at creation time.
Edm.DateTime This value is updated by Media Services after any property changes are made. It represents the number of milliseconds since midnight Jan 1, 1970.
Created

Read-only. Set by Media Services at creation time.
Edm.DateTime Represents the number of milliseconds since midnight Jan 1, 1970.
MimeType

Optional.
Edm.String Media Services does not inspect any blob that you uploaded, so you must manually set the mime type. For example, "text/plain" or "video/x-ms-wmv" are valid values to use. Maximum length is 4000.
ContentChecksum

Optional.
Edm.String A hexadecimal number representing a MD5 (RFC 1321) message digest value. This value is set by the client or client library to serve as a validation of the successful upload of the content. Maximum length is 4000.

Create an AssetFile

The CreateFileInfos function is used to create a new AssetFile entity. For more information, see REST API Functions.

List AssetFiles

AssetFiles are retrieved using a GET HTTP request.

Method Request URI HTTP Version
GET https://<accountname>.restv2.<location>.media.azure.net/api/Files HTTP/1.1
Method Request URI HTTP Version
GET https://<accountname>.restv2.<location>.media.azure.net/api/Files('fileid') HTTP/1.1
Method Request URI HTTP Version
GET https://<accountname>.restv2.<location>.media.azure.net/api/Assets('assetid')/Files HTTP/1.1

Sample Request

To get the latest x-ms-version:, see Media Services REST.

GET https://<accountname>.restv2.<location>.media.azure.net/api/Files('nb:cid:UUID:d0214595-fff0-164e-9c67-d576eba09605') HTTP/1.1  
Content-Type: application/json;odata=verbose  
Accept: application/json;odata=verbose  
DataServiceVersion: 3.0  
MaxDataServiceVersion: 3.0  
x-ms-version: 2.19  
Authorization: Bearer <token value>  
Host: media.windows.net  

Update an AssetFile

AssetFiles are updated using the MERGE HTTP request.

Method Request URI HTTP Version
MERGE https://<accountname>.restv2.<location>.media.azure.net/api/Files('fileid') HTTP/1.1

Sample Request

To get the latest x-ms-version:, see Media Services REST.

MERGE https://<accountname>.restv2.<location>.media.azure.net/api/Files('nb:cid:UUID:2710e174-3165-a34c-96ad-618714b0d504') HTTP/1.1  
Content-Type: application/json;odata=verbose  
Accept: application/json;odata=verbose  
DataServiceVersion: 3.0  
MaxDataServiceVersion: 3.0  
x-ms-version: 2.19  
Authorization: Bearer <token value>  
Content-Length: 27  
Expect: 100-continue  
  
{"MimeType" : "video/mp4" }  

Delete an AssetFile

AssetFiles are deleted when their associated Asset has been deleted. For an example, see Delete an Asset.

See Also

ContentKey
Asset
AccessPolicy
Job
JobTemplate
Locator
MediaProcessor
Task
TaskTemplate
Quotas and Limitations