Direct Upload
Upload files directly to Gumlet
Create Video Collection
To use direct-upload facility first step is to create a new video collection with Direct Upload as Collection Origin Type.
Once a collection is created you can use the direct-upload facility with either Gumlet Dashboard or REST APIs.
Using Dashboard
1. Go to the video manager of the above-created collection
2. Process new video and set necessary parameters
3. Upload Video File
Start uploading a video file by selecting it from the file browser.
After successful completion of the upload, you will be redirected back to the video manager.
4. Check Asset status in the video manager
Using REST APIs (Direct Upload)
1. Create an authenticated Gumlet URL
The first step is creating a new Direct Upload Asset with Asset Parameters as you want. The Gumlet API will return an authenticated URL that you can use directly, as well as an asset ID specific to that Direct Upload Asset so you can check the status later via the API or in Gumlet Video Manager.
curl -L -X POST 'https://api.gumlet.com/v1/video/assets/upload' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"source_id": <DIRECT UPLOAD COLLECTION ID>,
"format": "hls",
"resolution": ["240p", "360p", "720p", "1080p"],
"image_overlay": {
"url": "https://assets.gumlet.io/assets/logo.svg?format=png",
"height": "10%",
"width": "10%",
"horizontal_align": "left",
"horizontal_margin": "5%",
"vertical_align": "top",
"vertical_margin": "5%"
}
}'
{
"asset_id": "60c1b50a6676496c4bd9bec7",
"progress": 0,
"created_at": 1623307530439,
"status": "upload-pending",
"input": {
"transformations": {
"format": "hls",
"resolution": [
"240p",
"360p",
"720p",
"1080p"
],
"video_codec": [
"libx264"
],
"audio_codec": [
"aac"
],
"image_overlay": {
"url": "https://assets.gumlet.io/assets/logo.svg?format=png",
"vertical_align": "top",
"horizontal_align": "left",
"vertical_margin": "5%",
"horizontal_margin": "5%",
"width": "10%",
"height": "10%"
},
"thumbnail": [
"auto"
],
"thumbnail_format": "png",
"mp4_access": false,
"per_title_encoding": true,
"process_low_resolution_input": false,
"keep_original": true
},
"source_url": "60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/origin-60c1b50a6676496c4bd9bec7"
},
"output": {
"format": "hls",
"status_url": "https://api.gumlet.com/v1/video/assets/60c1b50a6676496c4bd9bec7",
"playback_url": "https://video.gumlet.io/60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/1.m3u8",
"thumbnail_url": [
"https://video.gumlet.io/60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/thumbnail-1-0.png"
]
},
"upload_url": "https://gumlet-video-user-uploads.s3.us-west-2.amazonaws.com/gumlet-user-uploads-prod/60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/origin-60c1b50a6676496c4bd9bec7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA4WNLTXWDOHE3WKEQ%2F20210610%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20210610T064530Z&X-Amz-Expires=3600&X-Amz-Signature=677006b4486468416c1af44dbb1a4482aaf50a714d1525745a2ff68f567d3164&X-Amz-SignedHeaders=host"
}
2. Use URL to upload a file
Once you have got upload_url
like in the above response example, you'll use the secured URL to make a PUT
request that includes the file in the body as following.
curl -v -X PUT -T video.mp4 <upload_url>
var fs = require('fs');
var request = require('request');
var options = {
'method': 'PUT',
'url': '<upload_url goes here>',
'headers': {
'Content-Type': 'video/mp4'
},
};
fs.readFile('video.mp4',(data, err) => {
if (!err) options.body = data;
});
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "<upload_url goes here>"
payload=open('video.mp4','r').read()
headers = {
'Content-Type': 'video/mp4'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('<upload_url goes here>');
$filename = "video.mp4";
$fp = fopen($filename, "r"); //open file in read mode
$contents = fread($fp, filesize($filename)); //read file
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'video/mp4'
));
$request->setBody($contents);
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
On successful completion of the cURL command, you should find new Assets in the Gumlet Video Manager with the settings you specified in the first step to create Direct Upload Asset.
3. Access uploaded video
You can access your uploaded video by using Video Asset Status API. You will receive original_download_url
field in response of the API which will contain a URL for accessing the uploaded video.
By default, Gumlet will keep your original videos in it's stoage space. If you don't want your original video to be stored on Gumlet storage then you can add keep_original
parameter with value false
in Create Asset API and Gumlet will delete your original video after processing.
Using REST APIs (Multipart Upload)
1. Create asset for upload
Same as Direct upload creating a new Upload Asset with Asset Parameters as you want.
curl -L -X POST 'https://api.gumlet.com/v1/video/assets/upload' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"source_id": <DIRECT UPLOAD COLLECTION ID>,
"format": "hls",
"resolution": ["240p", "360p", "720p", "1080p"],
"image_overlay": {
"url": "https://assets.gumlet.io/assets/logo.svg?format=png",
"height": "10%",
"width": "10%",
"horizontal_align": "left",
"horizontal_margin": "5%",
"vertical_align": "top",
"vertical_margin": "5%"
}
}'
{
"asset_id": "60c1b50a6676496c4bd9bec7",
"progress": 0,
"created_at": 1623307530439,
"status": "upload-pending",
"input": {
"transformations": {
"format": "hls",
"resolution": [
"240p",
"360p",
"720p",
"1080p"
],
"video_codec": [
"libx264"
],
"audio_codec": [
"aac"
],
"image_overlay": {
"url": "https://assets.gumlet.io/assets/logo.svg?format=png",
"vertical_align": "top",
"horizontal_align": "left",
"vertical_margin": "5%",
"horizontal_margin": "5%",
"width": "10%",
"height": "10%"
},
"thumbnail": [
"auto"
],
"thumbnail_format": "png",
"mp4_access": false,
"per_title_encoding": true,
"process_low_resolution_input": false,
"keep_original": true
},
"source_url": "60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/origin-60c1b50a6676496c4bd9bec7"
},
"output": {
"format": "hls",
"status_url": "https://api.gumlet.com/v1/video/assets/60c1b50a6676496c4bd9bec7",
"playback_url": "https://video.gumlet.io/60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/1.m3u8",
"thumbnail_url": [
"https://video.gumlet.io/60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/thumbnail-1-0.png"
]
},
"upload_url": "https://gumlet-video-user-uploads.s3.us-west-2.amazonaws.com/gumlet-user-uploads-prod/60c1af0c667649f5a0d9ada2/60c1b50a6676496c4bd9bec7/origin-60c1b50a6676496c4bd9bec7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA4WNLTXWDOHE3WKEQ%2F20210610%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20210610T064530Z&X-Amz-Expires=3600&X-Amz-Signature=677006b4486468416c1af44dbb1a4482aaf50a714d1525745a2ff68f567d3164&X-Amz-SignedHeaders=host"
}
2. Create parts of the original video
Create multiple parts of your video. Make sure each part is at least 5MB (unless the video size itself is less than 5MB then there will be only 1 part).
3. Sign part and upload
Get pre-signed upload URL for each part using the sign part API call. Use asset_id received from the upload new asset API call.
curl GET 'https://api.gumlet.com/v1/video/assets/{asset_id}/multipartupload/{part_number}/sign' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json'
{
"asset_id": "60c1b50a6676496c4bd9bec7",
"part_number": 1,
"part_upload_url": "https://gumlet-video-user-uploads.s3.us-west-2.amazonaws.com/gumlet-user-uploads-prod/600e2eccc1be63e7c5b29467/642db9d6cc22b56eb474a0c1/origin-642db9d6cc21a55eb474a0c1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA4WNLTXWDOHE3WKEQ%2F20230405%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20230405T181136Z&X-Amz-Expires=3600&X-Amz-Signature=23d23ca56dceab55ba16349609af7d0921361ced905dde848b6206aa3de0205a&X-Amz-SignedHeaders=host&partNumber=1&uploadId=rkY.tbFdsN14Obcdh.VpVvGdtVxipAa2dyKszL2g7ETT38TXucloiyJLtz9Ff79OgvM3tdsFdenolTgdaIy_jo7GyArbApbueZZ9oLM3k7tuHkX9wXyOMDbGRQ3V0q4W&x-id=UploadPart"
}
Upload the part using thepart_upload_url
.
curl -v -X PUT -T part_binary_data <part_upload_url>
Store the ETag
value of the response header for each part.
4. Complete multipart upload
Once you upload all the parts using their part_upload_url, complete the multipart upload using this API call. You need to send an array of PartNumber
and ETag
received while uploading part to S3
curl -L -X POST 'https://api.gumlet.com/v1/video/assets/{asset_id}/multipartupload/complete' \
-H 'Authorization: Bearer <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"parts": [
{"PartNumber": 1, "ETag":""1ae165be27bf32b6430c150620ee9b8f""},
{"PartNumber": 2, "ETag":""52e124ba4c6f32b31dac23e6033e9c4d""}
}
}'
{}
Updated 6 months ago