Socket
Socket
Sign inDemoInstall

@byteark/video-upload-sdk

Package Overview
Dependencies
23
Maintainers
6
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @byteark/video-upload-sdk

Uploading video files directly from user's browser to ByteArk Stream and Qoder


Version published
Weekly downloads
201
decreased by-17.28%
Maintainers
6
Created
Weekly downloads
 

Readme

Source

ByteArk Stream Video Upload SDK

Uploading video files directly from user's browser to ByteArk Stream and ByteArk Qoder service.

Installation

For Yarn:

yarn add @byteark/video-upload-sdk

For npm:

npm install --save @byteark/video-upload-sdk

Usage

Usage for ByteArk Qoder

The following variables should be replaced:

  • serviceName: byteark.qoder
  • serviceEndpoint
    • For frontend uploading: should be https://qoder.byteark.com/apps/<appId>/ajax, replacing appId with the application id.
  • FormId
    • Ask ByteArk admin for appId.
  • FormSecret
    • Ask ByteArk admin for appSecret.
  • projectKey
    • Project id that you want to upload.

Usage for ByteArk Stream

The following variables should be replaced:

  • serviceName: byteark.stream
  • serviceEndpoint
    • For frontend uploading: should be 'https://stream.byteark.com'.
  • FormId
  • FormSecret
  • projectKey
    • Project key that you want to upload.

Example Code

import { VideoUploadManager } from '@byteark/video-upload-sdk';

async function main() {
  const uploadManager = new VideoUploadManager({
    serviceName: 'byteark.qoder | byteark.stream',
    serviceEndpoint:
      'https://qoder.byteark.com/apps/<appIdHere>/ajax' |
      'https://stream.byteark.com',
    formId: '<AppId(Qoder)>' | '<FormId(Stream)>',
    formSecret: '<FormSecret>',
    projectKey: '<projectId(Qoder)>' | '<projectKey(Stream)>',
    onUploadProgress: (job: UploadJob, progress: UploadProgress) => {
      // Called when video uploading has a progress.
    },
    onUploadCompleted: (job: UploadJob) => {
      // Called when a video has uploaded.
    },
    onUploadFailed: (job: UploadJob, error: Error | DetailedError) => {
      // Called when video uploading failed (cannot retry).
    },
  });

  uploadManager.addUploadJob('<videoSourceFileId>', file1);
  uploadManager.addUploadJob('<videoSourceFileId>', file2);
  uploadManager.addUploadJob('<videoSourceFileId>', file3);
  await uploadManager.start();
}

main();

Getters

NameReturnsDescription
getJobQueueUploadJob[]Returns a job queue array.
getJobByUploadIdUploadJob | undefinedReturns a job that matches the provided uploadId.
getIsUploadStartedbooleanReturns true if any upload job has started.
getIsAllUploadCancelledbooleanReturns true if all jobs in a queue have been cancelled.

Methods

addUploadJobs(files: FileList): Promise<void>

Add videos that you want to upload. The SDK will create videos from the inputted files, trigger "onVideosCreated" callback, and add them to a job queue.

setOptions(newOptions: UploadManagerOptions): void

Set a new options to VideoUploadManager. This operation cannot be done when any upload job has already started.

start(): Promise<void>

Start uploading from a job queue.

pauseUploadById(uploadId: UploadId): Promise<UploadJob>

Pause a job by the provided uploadId.

This method throws an error when a job with the provided uploadId cannot be found.

resumeUploadById(uploadId: UploadId): Promise<UploadJob>

Resume a job by the provided uploadId.

This method throws an error when a job with the provided uploadId cannot be found.

cancelUploadById(uploadId: UploadId): Promise<UploadJob>

Cancel a job by the provided uploadId.

This method throws an error when a job with the provided uploadId cannot be found.

cancelAll(): Promise<void>

Cancel all jobs in a job queue.

Callbacks

onVideosCreated(videoKeys: string[])

Triggers after all videos are created on our service, which will happen after calling addUploadJobs(files) method.

onUploadStarted(job: UploadJob)

Triggers after the first upload job started uploading.

onUploadProgress(job: UploadJob, progress: UploadProgress)

Triggers periodically when upload job(s) are being uploaded.

onUploadCompleted(job: UploadJob)

Triggers after all upload jobs finished uploading.

onUploadFailed(job: UploadJob, error: Error | DetailedError)

Triggers when something happened while uploading and halted the uploader.

Example Application

We have an example application in

FAQs

Last updated on 20 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc