Direct Upload
Upload files directly to Gumlet
Using Dashboard
Upload your videos directly from the dashboard using this guide
Using REST APIs (Direct Upload)
1. Create an authenticated Gumlet URL
The first step is creating a new Direct Upload Asset with Asset Parameters per your requirements. The Gumlet API will return an authenticated URL that you can use directly, and an asset ID specific to that Direct Upload Asset so you can check the status later via the API or in Gumlet Dashboard.
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": <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%"
}
}'
2. Use the 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 follows:
curl -v -X PUT -T video.mp4 <upload_url>
<?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();
}
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)
On successful upload, the new assets will be available in the Gumlet Dashboard.
3. Access uploaded video
Access your uploaded video using the Video Asset Status API. You will receive the original_download_url
parameter.
By default, Gumlet will keep your original videos in its storage. 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
Create a new Upload Asset with Asset Parameters per your requirements.
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": <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%"
}
}'
2. Create parts of the original video
Create multiple parts of your video. Make sure each part is at least 5MB (unless the video is less than 5MB itself, then it will be only 1 part).
3. Sign part and upload
Get a 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'
Upload the part using the part_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 the 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""}
}
}'
Using REST API (Subtitle Upload)
1. Upload .srt file
Once you have got upload_url
by completing the Upload Subtitle API call. You need to attach your .srt file in body and use the PUT
request method.
curl --location --request PUT '<upload_url>' \
--data '<YOUR_FILE_PATH>'
on success you will get 200 OK
status
Updated 29 days ago