SPRZEDAŻ: 1-800-867-1389
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

Ingesting Assets with the Media Services REST API

Updated: February 14, 2014

Ingesting Assets into Microsoft Azure Media Services using the REST API involves multiple steps. For certain actions, such as encrypting an Asset, this requires you to perform multiple steps before interacting with Media Services. However, most actions, such as creating an Asset itself, are straightforward and simply require you to have a basic knowledge of REST principles, OData v3, and, in the case of the code examples, JSON.

The basic workflow for ingesting Assets is divided into the following sections:

For information on Ingesting Assets in Bulk, see Ingesting Assets in Bulk with the REST API.

noteNote
Media Services uses the value of the IAssetFile.Name property when building URLs for the streaming content (for example, http://{WAMSAccount}.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.

ImportantImportant
When working with the Media Services REST API, the following considerations apply:

Create the Asset

An asset is a container for multiple types or sets of objects in Media Services, including video, audio, images, thumbnail collections, text tracks, and closed caption files. In the REST API, creating an Asset requires sending POST request to Media Services and placing any property information about your asset in the request body.

The following example shows how to create an asset with the friendly name set to "NewJSONAsset."

POST https://media.windows.net/API/Assets HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1335602357&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=XQs5T%2fEfdO39%2f0Z9%2fBBkA12%2bbUUEY21YyefWXuRYZlY%3d
Host: media.windows.net
Content-Length: 27
Expect: 100-continue

{ "Name" : "NewJSONAsset" }

If successful, the following response is returned:

HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 1353
Content-Type: application/json;odata=verbose;charset=utf-8
Location: https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')
Server: Microsoft-IIS/7.5
x-ms-request-id: 7739638a-da3a-4a6e-ad51-ea0bf87f02ad
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 27 Apr 2012 22:39:18 GMT

{"d":{"__metadata":{"id":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')","uri":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')","type":"Microsoft.Cloud.Media.Vod.Rest.Data.Models.Asset","actions":{"https://media.windows.net/api/$metadata#WindowsAzureMediaServices.Publish":[{"title":"Publish","target":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')/Publish"}]}},"Locators":{"__deferred":{"uri":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')/Locators"}},"ContentKeys":{"__deferred":{"uri":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')/ContentKeys"}},"Files":{"__deferred":{"uri":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')/Files"}},"ParentAssets":{"__deferred":{"uri":"https://media.windows.net/api/Assets('nb%3Acid%3AUUID%3Aaa5bfdd9-900a-431d-aea7-fffb0b24f36b')/ParentAssets"}},"Id":"nb:cid:UUID:aa5bfdd9-900a-431d-aea7-fffb0b24f36b","State":0,"Created":"\/Date(1335566358610)\/","LastModified":"\/Date(1335566358610)\/","AlternateId":null,"Name":"NewJSONAsset","Options":0}}

For more information on Asset entity properties and operations, see Asset.

Encrypt the Asset (Optional)

Encrypting assets is an optional step. However, it is recommended to encrypt your assets. In Media Services, you could use: storage encryption of the asset's files or common encryption for managing DRM-protected files (for example, PlayReady). You could also use configuration encryption for encrypting encoding configuration data that may contain sensitive preset information. Each type of encryption requires an AES content key, X.509 certificate used to encrypt the content key, and corresponding properties to be set on Asset, ContentKey, and File entities. The content key lengths vary depending on the content key type. Storage and configuration encryption requires 256-bit keys, while common encryption requires a 128-bit key.

The following are general steps for encrypting files that you upload into blob storage:

  1. Randomly generate a 256-bit (32 byte) AES key. This will be the content key for your asset, which means all files associated with that asset will need to use the same content key during decryption.

  2. Randomly generate a 64-bit Initialization Vector (IV) value per file, ensuring that the IV value is unique for each file in the Asset.

  3. Create an Asset entity with the Options property set to "1" if you want for the asset files be encrypted after uploading (ingest). Set Options to "2" if you are using common encryption.

    noteNote
    This step can happen before or after you have performed steps 1 and 2.

  4. Call the GetProtectionKeyId and GetProtectionKey methods to get the correct X.509 Certificate that must be used to encrypt your content key.

  5. Encrypt your content key with the public key of the X.509 Certificate. Also create an MD5 checksum value based on the encrypted content key.

  6. Create a ContentKey entity and set the EncryptedContentKey (converted to base64-encoded string), ProtectionKeyId, ProtectionKeyType, ContentKeyType, and Checksum properties with the values you have received in previous steps.

  7. Associate the ContentKey entity with your Asset entity through the $links operation.

  8. After you have uploaded the file (described in the next section), call CreateFileInfos and update the encryption properties on the File entity with the values you created in previous steps.

ImportantImportant
Examples defining encryption keys have been omitted from this topic. Only the examples that show how to interact with Media Services are provided.

Retrieve the ProtectionKeyId

The following example shows how to retrieve the ProtectionKeyId, a certificate thumbprint, for the certificate you must use when encrypting your content key. Do this step to make sure that you already have the appropriate certificate on your machine.

GET https://media.windows.net/API/GetProtectionKeyId?contentKeyType=1 HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1335862109&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=ErOpftkPKjzX3bdYcEUZTK9yAwKIDc20y0kxEBZLvCk%3d
Host: media.windows.net

If successful, the following response is returned:

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 71
Content-Type: application/json;odata=verbose;charset=utf-8
Server: Microsoft-IIS/7.5
x-ms-request-id: 7940b777-4c95-4c68-9817-cd14d51ae2c4
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 30 Apr 2012 22:48:30 GMT

{"d":{"GetProtectionKeyId":"B2FE17BEF56FFCB9A3FC4267D0F2AFE25CD2DE22"}}

Retrieve the ProtectionKey

The following example shows how to retrieve the X.509 certificate using the ProtectionKeyId you received in the previous step.

GET https://media.windows.net/API/GetProtectionKey?ProtectionKeyId='B2FE17BEF56FFCB9A3FC4267D0F2AFE25CD2DE22' HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1335935139&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=s2dI0Ulkutx%2b5pTL0QGRnPQEv1Ogwz%2ff2SHRWK8bmyw%3d
Host: media.windows.net

If successful, the following response is returned:

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 1061
Content-Type: application/json;odata=verbose;charset=utf-8
Server: Microsoft-IIS/7.5
x-ms-request-id: 1a84817d-9967-4adc-92d9-5980b2cd5d45
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 01 May 2012 19:05:44 GMT

{"d":{"GetProtectionKey":"MIIDAjCCAe6gAwIBAgIQVq/2JBMjhoNDGQ93Rh6lhDAJBgUrDgMCHQUAMBkxFzAVBgNVBAMTDm5pbWJ1c2RldmNlcnQxMB4XDTExMDUwNDE4NDczOVoXDTM5MTIzMTIzNTk1OVowGTEXMBUGA1UEAxMObmltYnVzZGV2Y2VydDEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCd/070wkNh/UuXZNVIkc8uflSMm+Qy6RDoAwdnl3fispkbe28YbB6AMuENKq9UrfUigGf51+MKnLaojxwwpwS+kdrRh+qQ7LBM0tjQ4bK1Iq80Q8dyQLpqqo6v16NzAFVeE4jW5205Z93h8m3EatQyyCGFN38BF9iIICeiPEjEEq4utDzeHgQT82enAdkqZ5mxRtOY3u3yT9O9HbS+Ghkobgg+kdbHpWlhSwSEKh94ASLeJvazL154OvIqfgZ7DaKQ11uAFqx237rNdX+w7JYHUQ4AZK2ed5xXTcXMcerUtjJZ4jiky83WaP6wCMcaA4R+76x3q8B91Rs3LS9yyqmRAgMBAAGjTjBMMEoGA1UdAQRDMEGAEIZT7vc/79JcQWslkhGbOCahGzAZMRcwFQYDVQQDEw5uaW1idXNkZXZjZXJ0MYIQVq/2JBMjhoNDGQ93Rh6lhDAJBgUrDgMCHQUAA4IBAQAcMOz4ScCP8F0VRkPjWPWDrLwD1rj5lwOTXvEL8tR23nrifkWgFQgONzMndp+FIgtoMLfb+6Cs0ZkslL/8cJ3zYWx+e1pSZydV3Ke9oSOVLWbWBtQgniBdb/b+/ur53NEkNxWzkTcM9UCg/pcLs9sKja2Kz8R12FUaf+2fOUBf2m0oRM9cyvoeBiI2AHX6Uo2WXpJixa8ofydB94oAbt/04lDMAHryrD1BAJR76z3gB6PLb4L12LDqeXjAIc6hgtrNsYBJMQAv4KDHcmHW1601QGuQsy+V4I35Y7bOQUNyTZRlUpLu0E/RRVKjyyMBDTE0xXABt4w23nNyczpH/4U3"}}
noteNote
The certificate in the message body is base64-encoded and must be decoded before use.

Creating the ContentKey

After you have retrieved the X.509 certificate and used its public key to encrypt your content key, create a ContentKey entity and set its property values accordingly.

The following example shows how to create a ContentKey with a ContentKeyType set for storage encryption ("1") and the ProtectionKeyType set to "0" to indicate that the protection key Id is the X.509 certificate thumbprint. Also, you must define the Id, or Key Id of the ContentKey entity. This value must be a GUID value and follow the content identifier scheme nb:kid:UUID:GUID. For more information on content identifier schemes, see Identify Azure Media Services Entities and for more information on ContentKeys, see ContentKey.

POST https://media.windows.net/API/ContentKeys HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1336404839&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=JtpNaFsZWEq9WHl3zMcPbvxBg3HyfTRo%2fy7WEqNDFpw%3d
Host: media.windows.net
Content-Length: 223
Expect: 100-continue

{"Id" : "nb:kid:UUID:C02BB13C-94C3-426B-9DE3-1E331584EF7A", "ContentKeyType" : 1, "EncryptedContentKey" : "encrypted key value",  "ProtectionKeyId" : "B2FE17BEF56FFCB9A3FC4267D0F2AFE25CD2DE22", "ProtectionKeyType" : 0, "Checksum" : "checksum value"}

If successful, the following response is returned:

HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 614
Content-Type: application/json;odata=verbose;charset=utf-8
Location: https://media.windows.net/api/ContentKeys('nb%3Akid%3AUUID%3Ac02bb13c-94c3-426b-9de3-1e331584ef7a')
Server: Microsoft-IIS/7.5
x-ms-request-id: 1d990cfc-acf1-4838-9f6e-c9308e51279e
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 07 May 2012 05:34:01 GMT

{"d":{"__metadata":{"id":"https://media.windows.net/api/ContentKeys('nb%3Akid%3AUUID%3Ac02bb13c-94c3-426b-9de3-1e331584ef7a')","uri":"https://media.windows.net/api/ContentKeys('nb%3Akid%3AUUID%3Ac02bb13c-94c3-426b-9de3-1e331584ef7a')","type":"Microsoft.Cloud.Media.Vod.Rest.Data.Models.ContentKey"},"Id":"nb:kid:UUID:c02bb13c-94c3-426b-9de3-1e331584ef7a","Created":"\/Date(1336368841597)\/","LastModified":"\/Date(1336368841597)\/","ContentKeyType":1,"EncryptedContentKey":"encrypted key value","Name":null,"ProtectionKeyId":"B2FE17BEF56FFCB9A3FC4267D0F2AFE25CD2DE22","ProtectionKeyType":0,"Checksum":"checksum value"}}

After creating the ContentKey, associate it with your Asset using the $links operation, as shown in the following example:

POST https://media.windows.net/API/Assets('nb:cid:UUID:2973c0de-404e-4f21-83a3-efd6910a532b')/$links/ContentKeys HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fmediaservices.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1336404839&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=JtpNaFsZWEq9WHl3zMcPbvxBg3HyfTRo%2fy7WEqNDFpw%3d
Host: media.windows.net
Content-Length: 120

{"uri":"https://media.windows.net/api/ContentKeys('nb%3Akid%3AUUID%3Ac02bb13c-94c3-426b-9de3-1e331584ef7a')" }

If successful, a 204 response code is returned with no message body.

Upload a file to blob storage

Uploading a file to blob storage requires that you set the appropriate write permissions on the Asset, retrieve a URL to upload the file to, and finally, perform the actual upload using the Azure Storage REST APIs.

Set the AccessPolicy

Before uploading any files into blob storage, set the access policy rights for writing to an asset. To do that, POST an HTTP request to the AccessPolicies entity set. Define a DurationInMinutes value upon creation or you will receive a 500 Internal Server error message back in response. For more information on AccessPolicies, see AccessPolicy.

The following example shows how to create an AccessPolicy:

POST https://media.windows.net/API/AccessPolicies HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1335956356&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=1B1ysfYRcpI%2fQY9SSNIBBVBpgc67j4R2yXD7BCxs8D8%3d
Host: media.windows.net
Content-Length: 76
Expect: 100-continue

{"Name": "NewUploadPolicy", "DurationInMinutes" : "300", "Permissions" : 2 }

If successful, the following response is returned:

HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 526
Content-Type: application/json;odata=verbose;charset=utf-8
Location: https://media.windows.net/api/AccessPolicies('nb%3Apid%3AUUID%3A94763883-537a-41c0-a097-4e3f755bbeab')
Server: Microsoft-IIS/7.5
x-ms-request-id: 0a262141-e539-4fa6-b5d6-80cdf26d3ff6
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 02 May 2012 00:59:30 GMT

{"d":{"__metadata":{"id":"https://media.windows.net/api/AccessPolicies('nb%3Apid%3AUUID%3A94763883-537a-41c0-a097-4e3f755bbeab')","uri":"https://media.windows.net/api/AccessPolicies('nb%3Apid%3AUUID%3A94763883-537a-41c0-a097-4e3f755bbeab')","type":"Microsoft.Cloud.Media.Vod.Rest.Data.Models.AccessPolicy"},"Id":"nb:pid:UUID:94763883-537a-41c0-a097-4e3f755bbeab","Created":"\/Date(1335920371136)\/","LastModified":"\/Date(1335920371136)\/","Name":"NewUploadPolicy","DurationInMinutes":300,"Permissions":2}}

Now that you have created your AccessPolicy, link it to a Locator entity that will provide you a URL path to upload your file into blob storage.

Get the Upload URL

To receive the actual upload URL, create a Locator entity. Locators define the start time and type of connection endpoint for clients that want to access Files in an Asset. You can create multiple Locator entities for a given AccessPolicy and Asset pair to handle different client requests and needs. Each of these Locators use the StartTime value plus the DurationInMinutes value of the AccessPolicy to determine the length of time a URL can be used. For more information, see Locator.

noteNote
You cannot have more than five unique Locators associated with a given Asset at one time. For more information, see Locator.

TipTip
If you need to upload your files immediately, you should set your StartTime value to five minutes before the current time. This is because there may be clock skew between your client machine and Media Services. Also, your StartTime value must be in the following DateTime format: YYYY-MM-DDTHH:mm:ssZ (for example, "2014-05-23T17:53:50Z").

noteNote
There may be a 30-40 second delay after a Locator is created to when it is available for use. This issue applies to both SAS URL and Origin Locators.

The following example shows how to create a SAS URL Locator, as defined by the Type property in the request body. The Path property returned contains the URL that you must use to upload your file.

POST https://media.windows.net/API/Locators HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1335956356&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=1B1ysfYRcpI%2fQY9SSNIBBVBpgc67j4R2yXD7BCxs8D8%3d
Host: media.windows.net
Content-Length: 183
Expect: 100-continue

{"AccessPolicyId": "nb:pid:UUID:94763883-537a-41c0-a097-4e3f755bbeab", "AssetId" : "nb:cid:UUID:cab358e0-deaa-4c4f-9a9f-35687b54b0aa", "StartTime" : "2014-05-17T16:45:53", "Type" : 1 }

If successful, the following response is returned:

HTTP/1.1 201 Created
Cache-Control: no-cache
Content-Length: 1148
Content-Type: application/json;odata=verbose;charset=utf-8
Location: https://media.windows.net/api/Locators('nb%3Alid%3AUUID%3A8002bf3c-a215-4602-b4a4-2aac367f709e')
Server: Microsoft-IIS/7.5
x-ms-request-id: 6937fd51-70ad-4d3d-8138-991863906b43
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 02 May 2012 00:59:30 GMT

{"d":{"__metadata":{"id":"https://media.windows.net/api/Locators('nb%3Alid%3AUUID%3A8002bf3c-a215-4602-b4a4-2aac367f709e')","uri":"https://media.windows.net/api/Locators('nb%3Alid%3AUUID%3A8002bf3c-a215-4602-b4a4-2aac367f709e')","type":"Microsoft.Cloud.Media.Vod.Rest.Data.Models.Locator"},"AccessPolicy":{"__deferred":{"uri":"https://media.windows.net/api/Locators('nb%3Alid%3AUUID%3A8002bf3c-a215-4602-b4a4-2aac367f709e')/AccessPolicy"}},"Asset":{"__deferred":{"uri":"https://media.windows.net/api/Locators('nb%3Alid%3AUUID%3A8002bf3c-a215-4602-b4a4-2aac367f709e')/Asset"}},"Id":"nb:lid:UUID:8002bf3c-a215-4602-b4a4-2aac367f709e","ExpirationDateTime":"\/Date(1335938672000)\/","Type":1,"Path":"https://yourstorageaccount.blob.core.windows.net/asset-0a5ed405-ac50-45c7-a3bf-04d20eca17ad?st=2012-05-02T01%3A04%3A32Z&se=2012-05-02T06%3A04%3A32Z&sr=c&si=8002bf3c-a215-4602-b4a4-2aac367f709e&sig=r9IVlPDi4TfaCnG8fqpZUwr%2F3pMPsdFyVVYkwe6GKg0%3D","AccessPolicyId":"nb:pid:UUID:94763883-537a-41c0-a097-4e3f755bbeab","AssetId":"nb:cid:UUID:cab358e0-deaa-4c4f-9a9f-35687b54b0aa","StartTime":"\/Date(1335920672000)\/"}}

Preform the File Upload

Once you have the AccessPolicy and Locator set, the actual file is uploaded to an Azure Blob Storage container using the Azure Storage REST APIs. You can either upload in page or block blobs. For more information on uploading blobs, see Azure Storage Services REST API Reference.

The following example shows how to upload a block blob from the SDK media samples into the Asset container.

noteNote
You must add the file name for the file you want to upload to the Locator Path value received in the previous section. In this example, the file name is samplevid.wmv.

PUT https://yourstorageaccount.blob.core.windows.net/asset-9cd47271-9798-446f-b91d-22b0d228cc17/samplevid.wmv?st=2012-05-08T19%3A32%3A01Z&se=2012-05-09T00%3A32%3A01Z&sr=c&si=3e21040c-95d8-48b0-aee5-171d9621105d&sig=%2FSS6c%2FOELEtDfqi5TT7hFLYut38IKrV6iiQEhV2t52s%3D HTTP/1.1
Content-Type: application/octet-stream
x-ms-version: 2011-08-18
x-ms-date: 2011-01-17
x-ms-blob-type: BlockBlob
Host: yourstorageaccount.blob.core.windows.net
Content-Length: 4045744
Expect: 100-continue

wsh?1hfN??C?V??,?-?sd??:?j?dCfT?,?6????8?f?p??o??"?????6C??q?????KbP???w*????i
[Rest of binary data truncated for readability]

If successful, the following response is returned:

HTTP/1.1 201 Created
Transfer-Encoding: chunked
Content-MD5: 2Lzhghji5MH0CZ+EUidXyA==
Last-Modified: Tue, 08 May 2012 19:37:16 GMT
ETag: "0x8CEFB691BBEDD64"
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 4902799b-568f-49a8-893c-77fbee74ce18
x-ms-version: 2011-08-18
Date: Tue, 08 May 2012 19:37:15 GMT

0

Revoking the Upload URL (Optional)

After you have uploaded your file, you should DELETE the upload Locator to revoke write access to your Asset's blob storage container.

DELETE https://media.windows.net/api/Locators('nb%3Alid%3AUUID%3A81e5bd32-46ad-4d66-b7b8-50008ee4aec5') HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1336547485&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=ISzXspEIbgWifYYXqiPK1vo3%2bDHnTsX85umNxRjD3kQ%3d
Host: media.windows.net
Content-Length: 0

If successful, a 204 response code is returned with no message body.

Generating File Metadata

Now that you've uploaded your file, generate the File entity for it. This entity contains important metadata about your file and can be created by calling CreateFileInfos, as shown in the following example.

GET https://media.windows.net/api/CreateFileInfos?assetid='nb%3Acid%3AUUID%3Ac80d312d-7cb1-44aa-bb23-2c35d10c44bd' HTTP/1.1
Content-Type: application/json;odata=verbose
Accept: application/json;odata=verbose
DataServiceVersion: 3.0
MaxDataServiceVersion: 3.0
x-ms-version: 2.5
Authorization: Bearer http%3a%2f%2fschemas.xmlsoap.org%2fws%2f2005%2f05%2fidentity%2fclaims%2fnameidentifier=youraccountname&urn%3aSubscriptionId=2f84471d-b1ae-4e75-aa09-010f0fc0cf5b&http%3a%2f%2fschemas.microsoft.com%2faccesscontrolservice%2f2010%2f07%2fclaims%2fidentityprovider=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&Audience=urn%3aWindowsAzureMediaServices&ExpiresOn=1336547485&Issuer=https%3a%2f%2fwamsprodglobal001acs.accesscontrol.windows.net%2f&HMACSHA256=ISzXspEIbgWifYYXqiPK1vo3%2bDHnTsX85umNxRjD3kQ%3d
Host: media.windows.net
Content-Length: 0

If successful, a 204 response code is returned with no message body.

If you have encrypted any files, you need to update the properties on the File entity according to the table below. For an example on how to update an entity, see Managing Assets with the Media Services REST API. For more information on the File entity properties, see AssetFile.

 

Property Value Encryption Type

IsEncrypted

For storage and common encryption, the value must be set to "true".

Storage, Common

EncryptedKeyId

The encrypted ContentKey Id.

Storage

EncryptionScheme

For storage encryption, the value must be set to "StorageEncryption". For common encryption, the value must be set to "CommonEncryption".

Storage, Common

EncryptionVersion

The value must be set to "1.0."

Storage, Common

InitializationVector

Initialization vector value defined previously.

Storage

If successful, a 204 response code is returned with no message body.

See Also


Build Date:

2014-07-11
Czy oceniasz te materiały jako pomocne?
(Pozostało znaków: 1500)
Dziękujemy za opinię.

Zawartość społeczności

Dodaj
Pokaż:
© 2014 Microsoft