Reference Source Test
public class | source

Uploads

Extends:

events~EventEmittersrc/base.js~Base → Uploads

Uploads Class - Provides access to the Mux Video Uploads API

Example:

const { Video } = new Mux(accessToken, secret);

// Create an upload
Video.Uploads.create({ new_asset_settings: { playback_policy: 'public' } });

Test:

Method Summary

Public Methods
public

cancel(uploadId: string): Promise

Cancels an upload

public

create(params: Object): Promise

Creates a direct upload with the specified JSON parameters

public

get(uploadId: string): Promise

Get an upload

public

list(params: *): Promise

List all uploads

Public Methods

public cancel(uploadId: string): Promise source

Cancels an upload

Params:

NameTypeAttributeDescription
uploadId string

The ID for the upload intended for cancellation

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Cancels an upload
Video.Uploads.cancel(uploadId);

Test:

See:

public create(params: Object): Promise source

Creates a direct upload with the specified JSON parameters

Params:

NameTypeAttributeDescription
params Object

Upload JSON parameters (e.g timeout)

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const muxClient = new Mux(accessToken, secret);
const { Video } = muxClient;

// Create a new upload
const upload = await Video.Uploads.create({new_asset_settings: {playback_policy: 'public'}});
// Now push a file to the URL returned.
fs.createReadStream(pathToFile).pipe(request.put(upload.url))

Test:

See:

public get(uploadId: string): Promise source

Get an upload

Params:

NameTypeAttributeDescription
uploadId string

The ID for the upload

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// Get an upload
Video.Uploads.get(uploadId);

Test:

See:

public list(params: *): Promise source

List all uploads

Params:

NameTypeAttributeDescription
params *

Return:

Promise

Returns a resolved Promise with a response from the Mux API

Example:

const { Video } = new Mux(accessToken, secret);

// List all uploads
Video.Uploads.list();

Test:

See: