Skip to main content

Uploading With a Pre-Signed URL

When This Option Is Ideal

Use this when you have the video bytes already (on your server, in a browser upload, or on a device) and want the fastest, most reliable upload path.

The upload goes directly to object storage using a time-limited pre-signed URL. Your servers never proxy the file.

The Two-Step Process

  1. Request upload URL: Tell AntCDN how you want the video processed and get a pre-signed URL.
  2. Upload bytes: PUT the video file to the pre-signed URL.

Processing begins automatically after the upload finishes.

Step 1: Submit Video Config

POST https://api.antcdn.net/v1/videos/upload-url

Required Parameters

FieldTypeDescription
fileNamestringThe name of the file including its extension (e.g. demo.mp4)
allowPublicAccessbooleanWhether playback can be accessed without signing

Optional Parameters

FieldTypeDefaultDescription
videoNamestring-Display name for the video. Useful for finding the video in the dashboard or via API.
videoQualitystringstandardQuality preset: standard, high, ultra
maxEdgeLengthinteger-1Max short-edge resolution (e.g. 720, 1080, 2160). -1 means “auto”.
maxFrameRateinteger-1Max frame rate. -1 means “auto”.
encodingModestringfastfast or slow
audioCodecstringaacaac, aac-he, aac-he-v2, mp3, ac3, eac3
generateCaptionsbooleanfalseWhether captions should be generated automatically (if enabled for your plan)

Response body

{
"body": {
"assetId": "vid_XXX",
"signedURL": "https://<storage-provider>/<path>?<signature>",
"bucketPath": "<internal-bucket-path>",
"expiresAt": 1640995200
}
}
FieldTypeDescription
signedURLstringPre-signed URL for direct upload (valid for 1 hour)
expiresAtintegerUnix timestamp when the upload URL expires
assetIdstringYour new video (asset) ID

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. Once it’s ready, create (or use) an Edge Key and embed it:

<!-- Replace {edgeKey} with an Edge Key -->
<iframe
src="https://player.antcdn.net/v1/{edgeKey}/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);
});
};