Register an Asset via the API

< All Topics

Overview

Registering an Asset via BLAM API requires the triggering user to know two pieces of information:

  • FileStoreId of the file store containing the asset
  • Relative Path/Location of the Asset File within that location

This needs the File Store containing the Asset File (e.g. Local Disk, S3 Bucket) to have already been configured within the BLAM, giving the BLAM access and control of files in that location.

To then Register an Asset from a file in this location in the BLAM, you complete the following API calls in the specific order, as data returned from one will then be used as part of the input to the next.
For this guide we will use the example file ‘inputvideofile.mxf’ in the location ‘/blam/existing_content/video/inputvideofile.mxf’. The location ‘/blam/existing_content’ has been configured as FileStoreId 1. The Relative Path to this will is ‘/video/inputvideofile.mxf’.

Create the Asset

Using the Filename (without extension) of the File being Registered, you will first create the Asset within the BLAM.

Example Call

curl -H "Authorization: Bearer ${TOKEN}" -X POST https://yourblam.bluelucy.com/api/assets -H "Content-Type: application/json" --data "{ \"title\": \"inputvideofile\" }"

Example Response

    {
        "id": 1,
        "title": "inputvideofile",
        "dateCreated": "2020-08-21T14:39:50.603Z",
        "dateModified": "2020-08-21T14:39:50.603Z"
    }

The id of the returned response is the Asset ID of the new Asset that has been created.

Create the Asset Version

Using the Asset ID of the Asset created, and the Filename (with extension), you then create the first Asset Version in the BLAM.

Example Call

curl -H "Authorization: Bearer ${TOKEN}" -X POST https://yourblam.bluelucy.com/api/assets/versions -H "Content-Type: application/json" --data "{ \"assetId\": 1, \"originalFilename\": \"inputvideofile.mxf\" }"

Example Response

    {
        "id": 1,
        "assetId": 1,
        "originalFilename": "inputvideofile.mxf",
        "dateCreated": "2020-08-21T14:47:54.948Z"
    }

The id of the returned response is the Asset Version ID of the new Asset Version that has been created.

Create the Asset File

Now, use the Asset Version ID of the Asset Version created, the Filename (with extension), and specify the file type correctly as ‘video’, ‘audio’, ‘image’ or ‘document’ to create the first Asset File for the Asset Version.

Example Call

curl -H "Authorization: Bearer ${TOKEN}" -X POST https://yourblam.bluelucy.com/api/assets/versions/files -H "Content-Type: application/json" --data "{ \"versionId\": 1, \"tag\": \"Original\", \"originalFilename\": \"inputvideofile.mxf\", \"type\": \"video\", \"isMaster\": true }"

Example Response

    {
        "id": 1,
        "assetId": 1,
        "assetVersionId": 1,
        "type": "video",
        "tag": "Original",
        "originalFilename": "inputvideofile.mxf"
    }

The id of the returned response is the Asset File ID of the new Asset File that has been created.

Create the Asset File Location

Finally, using the Asset File Id of the Asset File created, and the File Store ID of the File Store (which you already have configured in the BLAM) where this Asset is located, and the specific relative location of the file within that File Store, create the Asset File Location for the Asset File.

For a Local Disk File Store, the Fields parameter must contain the Relative Path of the file:

"fields\": [ { "Relative Path": "video/inputvideofile.mxf" } ]

For a file stored in an S3 Bucket, the Fields will contain the Relative S3 File Key to the parent S3 Bucket:

"fields\": [ { "File Key": "file_location/inputfile.mxf" } ]

Example Call

curl -H "Authorization: Bearer ${TOKEN}" -X POST https://yourblam.bluelucy.com/api/assets/versions/files/locations -H "Content-Type: application/json" --data "{ \"assetFileId\": 1, ", \"fileStoreId\": 1, \"fields\": [ { \"Relative Path\": \"video/inputvideofile.mxf\" } ] }"

Example Response

    {
        "id": 1,
        "assetFileId": 1,
        "fileStoreId": 1,
        "fields": {
            "Relative Path": "video/inputvideofile.mxf"
        }
    }

The id of the returned response is the Asset File Location ID of the new Asset File Location that has been created.