Uploading a Video or Audio Asset: Four Steps

Only certain assets require uploading: video and audio files.

Note: For more information about Backlot REST API commands, see the Backlot API Reference.
You can upload a file all at once in a single request or in chunks with multiple requests.
Note: By default, after processing, assets are live (publicly viewable). If you do not want the asset to be immediately published after transcoding, set its status. See Setting an Asset's Post-processing Status.
Uploading a source file (video or audio) is a four-step process:
  1. Create the asset as detailed in Creating an Asset: POST.

    This returns the asset's identifier (called the embed_code)

  2. Retrieve the "uploading URLs" for the asset with GET /v2/assets/asset_id/uploading__urls
  3. For each file chunk, PUT to the URLs returned in Step 2. Do not sign these requests; see the explanation below.
  4. Mark the asset's status as uploaded with PUT /v2/assets/asset_id/upload_status.

To upload a video or audio file:

  1. Use POST with the /v2/assets route and properties in the request body. The following example creates the "My Video" video.
    Note: To upload the entire file at once, do not specify a chunk_size.
    [POST]/v2/assets{
       "name": "My Video",
       "file_name": "my_video.avi",
       "asset_type": "video",
       "file_size": 199895,
       "chunk_size": 100000
    }

    Backlot returns a response similar to the following.

    {
       "asset_type": "video",
       "duration": 0,
       "name": "My Video",
       "preview_image_url": null,
       "created_at": "2011-07-22T18:54:19+00:00",
       "embed_code": "Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl",
       "time_restrictions": null,
       "updated_at": "2011-07-22T18:54:19+00:00",
       "external_id": null,
       "description": null,
       "status": "uploading"
    }
    Note:

    Try out the code samples using your account credentials in the Ooyala Scratchpad. For information about using the Scratchpad, see Practice Making Requests with the Scratchpad. To launch the scratchpad, go to Ooyala API Scratchpad.

  2. Get the uploading URLs with GET /v2/assets, the asset ID, and the /uploading_urls qualifier.
    Note: If you are replacing an asset with the /replacement qualifier, get the uploading URLs with [GET] /v2/assets/asset_id/replacement/uploading_urls. See Replacing an Asset.
    The following example gets the uploading URLs for the asset with the ID Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl. This ID was returned as the embed_code of the previous response.
    [GET]/v2/assets/Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl/uploading_urls

    Backlot returns a response similar to the following.

    ["https://uploader-v2.ooyala.com/send?filename=Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl/0000000000000-0000000099999&filesize=100000 &expires=1311447448 &signature=tUp+iEUq9O9oP6khuasvZVFecoECcoej0gycG/ZTZr0", "https://uploader-v2.ooyala.com/send?filename=Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl/0000000100000-000000019989 &filesize=99895 &expires=1311447448 &signature=1aJ3ojLTUDnfLiHxZt/1us7jZ0StbtMC+pOnqNSQtiw"]
    Note:

    Try out the code samples using your account credentials in the Ooyala Scratchpad. For information about using the Scratchpad, see Practice Making Requests with the Scratchpad. To launch the scratchpad, go to Ooyala API Scratchpad.

  3. Upload each chunk.

    If you didn't specify a chunk_size, do not specify a chunk range. The following example uploads the first chunk of the Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl asset.

    Note: Do not sign this request, as you would other requests. Simply PUT the chunk contents to the exact URLs. These URLs have already been signed for you.
    [PUT]https://uploader-v2.ooyala.com/send?filename=Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl/0000000000000-0000000099999 &filesize=100000 &expires=1311447448 &signature=tUp+iEUq9O9oP6khuasvZVFecoECcoej0gycG/ZTZr0 <file>
  4. To indicate that the video is ready for processing, use PUT /v2/assets, the asset ID, the /upload_status qualifier, and the status property in the request body as uploaded. The following example marks the Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl asset as uploaded.
    [PUT]/v2/assets/Y1dTdvMjq9QtOMGrP-H59OIgiZ6-_Mrl/upload_status{
       "status": "uploaded"
    }

    Backlot returns a response similar to the following and starts processing the video.

    {
       "status": "uploaded"
    }
    Note:

    Try out the code samples using your account credentials in the Ooyala Scratchpad. For information about using the Scratchpad, see Practice Making Requests with the Scratchpad. To launch the scratchpad, go to Ooyala API Scratchpad.

The video is successfully uploaded.

Was this article helpful?