Skip to main content

Upload From Your Local

BlendVision One provides the capability to upload video files directly from your local device for the encoding jobs.

File TypeAccepted FormatsMaximum Size
Videoavi,.mpg,.mp4,.ts,.m2ts,.mov,.mkv,.wmv70 GB

Here are the steps to complete this process:

Obtain Upload URLs

Upload URL is an on-demand presigned location where you can place your file.

To obtain the URL for loading a file, make a POST request to the following API with the name and size of your file specified in the request body:

POST /bv/cms/v1/library/files:upload

Here is an example of the request body:

"file":{
"type":"FILE_TYPE_VIDEO",
"source":"FILE_SOURCE_ADD_VOD",
"name":"file_name",
"size":"file_size_in_bytes"
}

When you request to upload a file that exceeds 100MB, multiple URLs will be provided and you will need to split your file into pieces and upload them onto each URL separately (5MiB-5GiB per each, no limit for the last piece).

Here's an example of the response:

{
"file":{
"id":"library-id",
"upload_data":{
"id":"upload-id",
"parts":[
{
"part_number":0,
"presigned_url":"string"
},
{
"part_number":1,
"presigned_url":"string"
}
]
}
}
}

In the response:

  • The id within the file object represents the library ID of the file.
  • The id inside the upload_data object denotes the upload ID of the file.

Upload File using Multipart Upload

To facilitate efficient and smooth uploads, your file should be partitioned into specified parts and utilize the provided presigned_url for uploading each segment through the PUT method. Each part is a contiguous portion of the file's data. You can upload these object parts independently and in any order.

Step 1. Upload File Parts

It's recommended to upload these parts in parallel but with a restricted capacity to ensure efficient and smooth uploads. Implementing a retry mechanism ensures that any failed uploads are reattempted, and the ability to resume from break-points is invaluable for large files.

Here's a pseudo-code to demonstrate the process:

// Function to upload file parts based on the response received from step 1
function uploadFileParts(response):
// Extract parts information from the response
parts = response.file.upload_data.parts
// Set the limit for parallel uploads
parallelUploadsLimit = 5
// Initialize the count of active uploads
activeUploads = 0
// Set the limit for retries in case of upload failure
retryLimit = 3
// Initialize a queue to manage parts waiting to be uploaded
uploadQueue = initializeQueue(parts)
// List to keep track of successfully uploaded parts
completedParts = []

// Continue uploading until all parts are uploaded or the queue is empty
while not uploadQueue.isEmpty() or activeUploads > 0:
// Check if we can start a new upload
if activeUploads < parallelUploadsLimit and not uploadQueue.isEmpty():
// Dequeue the next part from the queue
part = uploadQueue.dequeue()
// Increment the count of active uploads
activeUploads += 1
// Start uploading the part with a retry limit
uploadPart(part, retryLimit)

// Check for completed uploads and update the active uploads count
checkCompletedUploads(completedParts, activeUploads)

// Check if all parts have been uploaded successfully
if len(completedParts) == len(parts):
return "All parts uploaded successfully"
else:
return "Some parts failed to upload"

// Function to upload a single part with retry mechanism
function uploadPart(part, retryLimit):
// Initialize retry count and success flag
retries = 0
success = false

// Retry uploading the part until the retry limit is reached or upload is successful
while retries < retryLimit and not success:
try:
// Attempt to upload the part to the presigned URL
uploadToPresignedUrl(part.presigned_url, part)
// Add the part to the list of completed parts upon successful upload
completedParts.append(part)
// Set success flag to true
success = true
except UploadError:
// Increment the retry count in case of an upload error
retries += 1
// Log the failure if the retry limit is reached
if retries == retryLimit:
log("Part " + part.part_number + " failed to upload after " + retryLimit + " retries.")

// Function to upload a part to the presigned URL using the PUT method
function uploadToPresignedUrl(presignedUrl, part):
// Implement the code to upload the part to the presigned URL using the PUT method
// This can be done using a library or built-in functionality for HTTP requests

// Function to check for completed uploads and update the active uploads count
function checkCompletedUploads(completedParts, activeUploads):
for part in completedParts:
// Check if the part upload is completed
if part.uploadCompleted():
// Decrement the active uploads count
activeUploads -= 1
// Remove the part from the list of completed parts
completedParts.remove(part)

// Call the function with the response from Step 1
uploadFileParts(response)

This pseudo-code outlines a process where file parts are uploaded in parallel, with a limit on the number of simultaneous uploads. Each part is retried up to a specified limit if the upload fails. The process checks for completed uploads and removes them from the active queue, allowing new uploads to start. If all parts are uploaded successfully, it returns a success message; otherwise, it indicates that some parts failed to upload.


Step 2. Register for the Uploaded Files

After uploading all pieces of the file to the URLs as obtained in Step 1, send a registration request for the file using the following API:

POST /bv/cms/v1/library/files/{id}:complete-upload

Replace the path parameter id with the library ID of uploading file.

Here's an example of the request body:

"complete_data":{
"checksum_sha1":"base64-encoded-SHA-1-160bit-digest",
"id":"upload-id",
"parts":[
{
"etag":"uploaded-part-ETag",
"part_number":1
}
]
}

In the request:

  • The checksum_sha1 represents the base64-encoded, 160-bit SHA-1 digest of the original file content.
  • The parts array contains objects that detail each uploaded part, specifying its ETag and the associated part number.

Workflow diagram