Sheharose
Sheharose

Reputation: 295

Download asset file from asset in Azure media service

I have an issue. I have an asset in the azure media service. The asset contains an asset file. I would like to know how to download the asset file. I'm using httparty gem for this.

HTTParty.get(https://<host>.restv2.<location>.media.azure.net/api/Files('<file_id>'), headers: headers)

The headers have the authorization value. The above request gives the metadata of the asset file but I would like to download the asset file. Can anyone please help. Thanks. I have gone through the below documentation: https://learn.microsoft.com/en-us/rest/api/media/operations/assetfile

Upvotes: 1

Views: 2113

Answers (1)

Sanjid
Sanjid

Reputation: 133

You have to create a SAS locator for the parent asset which will return a SAS URL for the asset, something like:

https://[storageaccount].blob.core.windows.net/asset-[parentAssetId]?[queryparams]

Sending a GET request with the asset file name appended to the SAS URL will return the assetfile contents:

GET https://[storageaccount].blob.core.windows.net/asset-[parentAssetId]/[assetFileName]?[queryparams]

Here is a .NET example. You can ignore the job reference bits and it should work with any asset.

I also find it very helpful to use the Azure Media Services Explorer along with Fiddler to figure out the REST requests needed for different workflows.

Upvotes: 2

Related Questions