Skip to main content
Version: JavaScript SDK v1.1.0

Upload Video

You can upload video files to our platform using File object and UploadManager. The video file should be in mp4 format and the file size should not exceed 100 MB.

try {
const upload = UploadManager.uploadFile(file, {
title: 'My new video',
metadata: {
'breed': 'persian'
},
tags: ['cats']
})
} catch (error) {
// Handle errors
}

If the file meets the requirements the upload manager returns Upload object, which can be used for tracking upload progress, upload state or canceled upload.

upload.subscribe('error', (event, { error }) => {
// Handle uploading error
})

upload.subscribe('progress', (event, { progress }) => {
console.log(`Uploading progress: ${progress * 100}%`)
})

upload.subscribe('stateChanged', (_, { state }) => {
if (state === UploadState.INITIALIZING) {
// Video uploading was initialized
// Upload manager creates video object and prepares storage url for uploading
} else if (state === UploadState.UPLOADING) {
// Video is being uploaded
} else if (state === UploadState.UPLOADED) {
// Video was uploaded to storage, but can't be played yet
} else if (state === UploadState.READY_TO_PLAY) {
// Video is ready to play, you can play it using player component
player.setVideo(upload.video)
}
})

If you changed your mind and want to cancel uploading, you can do it using the cancel() method.

upload.cancel()