Skip to main content
Version: 0.1.x

Generate presigned URL - Android

You have the option to create presigned URL, allowing you to upload your recordings to AWS, Azure, or GCP securely. presigned URL provide a secure and temporary way to upload objects to your cloud storage. Instead of sharing your entire credentials, you can create a special URL that allows uploading a specific file for a limited time.

important

While presigned URL offer a convenient way to upload files securely, each cloud provider (AWS, Azure, and GCP) might have different restrictions on how they work. It's advisable to refer the respective documentation for AWS, Azure, and GCP to gain a clearer understanding of presigned URL.

Code Sample

This guide will walk you through the process of generating a presigned URL for uploading recordings to your cloud storage of choice. You can use this generated presigned URL in Start Recording API.

const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");
const { getSignedUrl } = require("@aws-sdk/s3-request-presigner");
import fetch from 'node-fetch';

const region = <YOUR S3 REGION>;
const bucket = <YOUR S3 BUCKET NAME>;
const key = <YOUR FILE NAME>; // test/abc.mp4
const accessKeyId = <YOUR S3 ACCESS KEY ID>;
const secretAccessKey = <YOUR S3 SECRET ACCESS KEY>;
const expiresIn = <URL EXPIRY IN SECONDS>; // this number should be higher than duraion of recording

const s3Client = new S3Client({
credentials: {
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
},
region: region,
});

const createPresignedUrlWithClient = async () => {
const command = new PutObjectCommand({ Bucket: bucket, Key: key });
const preSignedUrl = await getSignedUrl(s3Client, command, { expiresIn: expiresIn });
return preSignedUrl;
};

// you can use this presigned url like this
async function main() {
let preSignedUrl = await createPresignedUrlWithClient();
const options = {
method: "POST",
headers: {
Authorization: "$YOUR_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
roomId: "abcd-efgh-ijkl",
preSignedUrl: preSignedUrl
}),
};
const url = `https://api.videosdk.live/v2/recordings/start`;
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
}

main();

API Reference

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord


Was this helpful?