Skip to content

Uploading Videos

Uploading videos at Zustack.

Learn how to upload videos to Zustack using the API.

Video files are uploaded using multipart upload, which splits large files into smaller chunks for more reliable and resumable transfer.


Before you begin, make sure you have:

  • A bucket created
  • A JWT signed with your API Key with the scope claim set to write.

ParameterTypeDescription
bucket_idstringThe ID of your target bucket.
accessstringCan be public or private.
client_idstringA unique identifier for your video upload.
filefileA single video chunk (video/*).
thumbnailfileOptional thumbnail image for the video (image/*).
chunk_numberstringThe current chunk number (starting from 0).
total_chunksstringTotal number of chunks for the upload (starting from 1).
resolutionstringDesired video resolution, e.g., 1920x1080 1280x720.
timeline_previewstringyes or no whether to generate a timeline preview.

Assuming you have a video file, use split to divide it into 5MB chunks with a video file of 10MiB for this example:

Terminal window
mkdir ~/out
cp ~/path/to/video.mkv ~/out/input.mkv
split -b 5M --numeric-suffixes=1 --additional-suffix=.mkv ~/out/input.mkv ~/out/chunk_
mv ~/out/chunk_01.mkv ~/out/video.mkv
Terminal window
export BUCKET_ID=your_bucket_id
export JWT=your_jwt_token
export ACCESS=public
export CLIENT_ID=some_long_id
export PATH_TO_CHUNK=@/path/to/out/video.mkv
export PATH_TO_THUMBNAIL=@/path/to/image.png
export CHUNK_NUMBER=0
export TOTAL_CHUNKS=2
export RESOLUTION="1920x1080 1280x720"
export TIMELINE_PREVIEW=yes
Terminal window
curl -X POST "https://zustack.com/files/upload/video/${BUCKET_ID}" \
-H "Authorization: Bearer ${JWT}" \
-H "Content-Type: multipart/form-data" \
-F "access=${ACCESS}" \
-F "client_id=${CLIENT_ID}" \
-F "chunk_number=${CHUNK_NUMBER}" \
-F "total_chunks=${TOTAL_CHUNKS}" \
-F "resolution=${RESOLUTION}" \
-F "timeline_preview=${TIMELINE_PREVIEW}" \
-F "file=${PATH_TO_CHUNK};type=video/x-matroska" \
-F "thumbnail=${PATH_TO_THUMBNAIL}"

Each successful chunk upload will return a 200 OK response.

When chunk_number is equal to total_chunks - 1, you’re uploading the final chunk.

Terminal window
mv ~/out/video.mkv ~/out/chunk_01.mkv
mv ~/out/chunk_02.mkv ~/out/video.mkv
export CHUNK_NUMBER=1
Terminal window
curl -X POST "https://zustack.com/files/upload/video/${BUCKET_ID}" \
-H "Authorization: Bearer ${JWT}" \
-H "Content-Type: multipart/form-data" \
-F "access=${ACCESS}" \
-F "client_id=${CLIENT_ID}" \
-F "chunk_number=${CHUNK_NUMBER}" \
-F "total_chunks=${TOTAL_CHUNKS}" \
-F "resolution=${RESOLUTION}" \
-F "timeline_preview=${TIMELINE_PREVIEW}" \
-F "file=${PATH_TO_CHUNK};type=video/x-matroska" \
-F "thumbnail=${PATH_TO_THUMBNAIL}"

FieldTypeDescription
file_idstringA unique ID for the uploaded video
video_lengthstringThe duration of the video in seconds
{
"file_id": "2f5c8e31-9d47-402a-995e-8cbbd8120373"
"video_length": "120"
}

Once the file is uploaded, Zustack will send relevant information about the file to the webhook only if it is configured.

The data sent will include:

  • file_id: The ID of the created file.
  • media_url: The URL of the file.
  • status: The status of the file.

Make sure your bucket’s webhook is properly set up to receive these notifications.

Any video files uploaded using multipart uploads will be automatically deleted after 24 hours if the upload is not completed. Make sure to finalize your upload within this time frame to avoid data loss.