Use CDN file upload with Streams
By using the direct file upload API you can upload your local video assets to our CDN and use it to create a new Stream.
Step 1
Request a signed URL for file uploading.
curl --request POST \
--url https://api.bitmovin.com/v1/encoding/inputs/direct-file-upload \
--header 'X-Api-Key: xxxx-xxxx-xxxx-xxxx' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"name": "your input name",
}
'
Step 2
Extract data.result.id
and data.result.uploadUrl
from the response, you will need them in the next steps.
{
"requestId": "xxxx-xxxx-xxxx-xxxx",
"status": "SUCCESS",
"data": {
"result": {
"id": "xxxx-xxxx-xxxx-xxxx",
"name": "your input name",
"createdAt": "2023-03-30T09:31:37Z",
"modifiedAt": "2023-03-30T09:31:37Z",
"uploadUrl": "https://bitmovin-direct-file-upload-storage-eu-west-1.s3.eu-west-1.amazonaws.com/xxxx-xxxx-xxxx-xxxx"
},
"messages": [
{
"id": "xxxx-xxxx-xxxx-xxxx",
"date": "2023-03-30T09:31:37Z",
"type": "INFO",
"text": "Successfully created direct file upload input!"
}
]
}
}
Step 3
Upload your video asset to the uploadUrl
you received from the response in Step 2
The returned
uploadUrl
is only valid for 5 minutes. Should it expire you need to request a new one
curl -X PUT \
-T "test.mov" \
"https://your-upload-url-from-step2"
Step 4
Once your file has been uploaded, you can use its id
property (that we also received as part of the result inStep 2
) and construct the input asset URL and create a new Stream.
Asset URLs from the direct file upload input have the following format:
https://api.bitmovin.com/v1/encoding/inputs/direct-file-upload/${inputId}
curl --request POST \
--url https://api.bitmovin.com/v1/streams/video \
--header 'X-Api-Key: xxxx-xxxx-xxxx-xxxx' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"title": "Stream Title",
"assetUrl": "https://api.bitmovin.com/v1/encoding/inputs/direct-file-upload/${inputId}"
}
'
There you go, a new Stream is created and ready to be published 🎉
{
"status": "SUCCESS",
"requestId": "5b5c19cc-6ca0-4efb-8b7d-978a49fd290c",
"data": {
"result": {
"id": "cgimtnajb2qhs398hfs0",
"assetUrl": "https://cdn.bitmovin.com/content/assets/streams-sample-video/bbb/m3u8/index.m3u8",
"title": "Stream Title",
"createdAt": "2023-03-30T11:13:33Z",
"status": "PUBLISHED",
"encodingTasks": []
}
}
}
The response contains the streamId
in the data.result.id
field, which you can use to embed and share your Stream.
If you need more information on how to share or embed your Stream, make sure to check out our product guides for the webcomponent, iframe embed and sharing options
Updated over 1 year ago