Download files from an MK.IO Asset via API
Introduction
The MK.IO API allows users to download files stored in an asset. This is a two step process:
- Get file access information using the getFileAccessInfo API
- Use the information returned to access a specific file
Pre-requisites:
- One or more assets defined in MK.IO with content
- A personal access token, once can be generated in the user profile page of MK.IO (or via the tokens API)
- The name of the project in which the asset exists
- The name of the asset
- The path and name of the file to access
The following example uses the VSCode REST Client plugin to make an HTTP POST request to the getFileAccessInfo API:
@project = demo-library
@asset = privateOfferAcceptancePublic
###
# @name getFileAccessInfo
POST {{mkioBaseURL}}/api/v1/projects/{{project}}/media/assets/{{asset}}/getFileAccessInfo HTTP/1.1
Authorization: Bearer {{prod_token}}
The prod_token variable in the above is declared elsewhere, but is the personal access token mentioned in the pre-requisites.
The response will contain several fields which can be declared as variables:
###
@jwt = {{getFileAccessInfo.response.body.jwt}}
@url = {{getFileAccessInfo.response.body.url}}
@storageAccountName = {{getFileAccessInfo.response.body.storageAccountName}}
@containerName = {{getFileAccessInfo.response.body.containerName}}
Note that if you used a subpath of the asset to store content, this will also be returned in the body of the response and will need to be used in the file path of the following.
Get Files from Object Storage
The storageAccountName and containerName in above variables are then used in the body of a the request to the url appended by "/downloadBlob" with the jwt as the Authorization Bearer, thus:
###
# @name downloadBlob
POST {{url}}downloadBlob
Authorization: Bearer {{jwt}}
Content-Type: application/json
{
"storageAccountName": "{{storageAccountName}}",
"containerName": "{{containerName}}",
"fileName": "PrivateOfferAcceptance.mpd"
}
Related Articles
How to use MK.IO APIs - step by step
Update December 2024: Note that https://docs.mk.io/docs/api-tokens describes the steps to manage personal tokens when using MK.IO APIs ...
How to migrate all your content from AMS into MK.IO using MK.IO bulk migration tool
In this article we will describe in detail the process to migrate all your assets, asset filters, streaming locators, content key policies, streaming endpoints from AMS into MK.IO. The idea is that if today you have a playback URL in the following ...
How to use DRM to playback MK.IO assets encrypted
Intro Currently, MK.IO solution supports only MediaKind's DRM solution as the unique provider of DRM encryption keys. External 3PP Key Management System solutions will be considered. In MK.IO there are the following groups of encryptions: 1. ...
How to find MK.IO Customer ID and Subscription ID
This article will describe the step by step on how to find the Customer ID and Subscription ID Below are the instructions to find the customer id: Login to the MK.IO portal https://app.mk.io/ Choose your subscription. Once logged, open another tab in ...
Updating Azure SAS Token for Asset Storage
You have created a storage account in MK/IO by linking your Azure blob storage, linked a container and processed assets. However once the SAS token expires to the storage account, these assets will not be accessible until you edit/update the Storage ...