Skip to main content

Uploading With a Pre-Signed URL

When This Option Is Ideal

You’ve got a video locally. Maybe it’s on your server, maybe it’s on your user’s phone.

You want to make this video playable for everyone else.

Follow this guide. We’ll show you how to get that video ready to be played back for anyone.

The Two-Step Process

This workflow has two steps:

  1. Video Config. Tell Hesedvid things like the video quality and resolutions you want available. You’ll get a pre-signed URL back.
  2. Video Upload. You’ll get a pre-signed URL from step one. Upload this video to the pre-signed URL.

Step 1: Submit Video Config

POST https://api.hesedvid.com/v1/{orgID}/environments/{envID}/videos/upload-url

Required Parameters

FieldTypeDescription
fileNamestringThe name of the file including the file extension
videoQualitystringQuality preset: standard, high, ultra
allowPublicAccessbooleanWhether video can be accessed without authentication

To decide on which video quality you might want to use, click here.

Caution

TODO: We need a comparison page

Optional Parameters

FieldTypeDefaultDescription
videoNamestring-Display name for the video. Useful for finding the video in the dashboard or via API.
maxEdgeLengthinteger(auto-detected)Maximum resolution: 480, 720, 1080, 1440, 2160
maxFrameRateinteger(auto-detected)Maximum frame rate (fps)
EncodingModestringfastEither fast or slow. Use slow for better quality and slightly faster loading speed.
audioCodecstringaacAudio codec: aac, mp3, ac3, eac3

To see the quality difference of the fast or slow encoding mode, click here.

Caution

TODO: We need a comparison page for encoding mode too.

Response body

{
"body": {
"videoID": "pubvid_XXX",
"signedURL": "https://storage.googleapis.com/hesedvid-uploads/org_123/env_prod/videos/uuid-123.mp4?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=...",
"expiresAt": 1640995200
}
}
FieldTypeDescription
signedURLstringPre-signed URL for direct upload (valid for 1 hour)
expiresAtintegerUnix timestamp when the upload URL expires

Step 2: Upload To Pre-Signed URL

Open your video file and make a “PUT” request to the signedURL you got from step 1.

file, _ := os.Open(filePath)
defer file.Close()
putReq, _ := http.NewRequest("PUT", `<signedURL>`, file)
client.Do(putReq)

Code Examples


View:

How To Play The Video You Just Uploaded

After you upload your video, it will begin processing. When it’s done processing, you can take the public Video ID you got from step 1 and start to play the video:

<!-- Replace the {vidID} with the public video ID from step 1 -->
<iframe
src="https://player.hesedvid.com/v1/public/{orgID}/{envID}/{vidID}/master.m3u8?autoplay=true&muted=true"
frameborder="0"
allowfullscreen>
</iframe>

Check out our “Video Player” docs for more information.

Bonus: Upload Progress Tracking

For large files, you may want to track upload progress:

const uploadWithProgress = async (file, signedURL) => {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.upload.addEventListener('progress', (event) => {
if (event.lengthComputable) {
const percentComplete = (event.loaded / event.total) * 100;
console.log(`Upload progress: ${percentComplete.toFixed(2)}%`);
}
});
xhr.addEventListener('load', () => {
if (xhr.status === 200) {
resolve('Upload complete');
} else {
reject(new Error('Upload failed'));
}
});
xhr.open('PUT', signedURL);
xhr.setRequestHeader('Content-Type', file.type);
xhr.send(file);
});
};