Skip to content

Commit

Permalink
Add action
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierapivideo authored Nov 10, 2023
1 parent bac474d commit 50030bf
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions templates/documentation/sdks/vod/apivideo-typescript-uploader.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
---
title: api.video TypeScript video uploader
meta:
description: The official api.video TypeScript video uploader for api.video. [api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
---

# api.video TypeScript video uploader

[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

## Project description

Expand Down Expand Up @@ -102,15 +93,15 @@ Then, once the `window.onload` event has been trigered, create your player using

## Documentation - Standard upload

### Instantiation
### Instanciation

#### Options

The upload library is instantiated using an `options` object. Options to provide depend on the way you want to authenticate to the API: either using a delegated upload token (recommanded), or using a usual access token.
The upload library is instanciated using an `options` object. Options to provide depend on the way you want to authenticate to the API: either using a delegated upload token (recommanded), or using a usual access token.

##### Using a delegated upload token (recommended):

Using delegated upload tokens for authentication is best options when uploading from the client side. To know more about delegated upload token, read the dedicated article on api.video's blog: [Delegated Uploads](https://api.video/blog/tutorials/delegated-uploads/).
Using delegated upload tokens for authentication is best options when uploading from the client side. To know more about delegated upload token, read the dedicated article on api.video's blog: [Delegated Uploads](https://api.video/blog/tutorials/delegated-uploads).


| Option name | Mandatory | Type | Description |
Expand Down Expand Up @@ -180,7 +171,7 @@ On fail, the promise embeds the status code & error message returned by the API.
**Example**

```javascript
// ... uploader instantiation
// ... uploader instanciation

uploader.upload()
.then((video) => console.log(video))
Expand All @@ -198,10 +189,15 @@ An onProgress event contains the following attributes:
- currentChunk (number): index of the chunk being uploaded
- currentChunkUploadedBytes (number): number of bytes uploaded for the current chunk

#### `cancel()`

The cancel() method cancels the upload. It takes no parameter.


**Example**

```javascript
// ... uploader instantiation
// ... uploader instanciation

uploader.onProgress((event) => {
console.log(`total number of bytes uploaded for this upload: ${event.uploadedBytes}.`);
Expand All @@ -224,7 +220,7 @@ The onPlayable() method let you defined a listener that will be called when the
<div id="player-container"></div>

<script>
// ... uploader instantiation
// ... uploader instanciation
uploader.onPlayable((video) => {
// the video is playable, we can display the player
Expand All @@ -236,15 +232,15 @@ The onPlayable() method let you defined a listener that will be called when the
## Documentation - Progressive upload


### Instantiation
### Instanciation

#### Options

The progressive upload object is instantiated using an `options` object. Options to provide depend on the way you want to authenticate to the API: either using a delegated upload token (recommanded), or using a usual access token.
The progressive upload object is instanciated using an `options` object. Options to provide depend on the way you want to authenticate to the API: either using a delegated upload token (recommanded), or using a usual access token.

##### Using a delegated upload token (recommended):

Using delegated upload tokens for authentication is best options when uploading from the client side. To know more about delegated upload token, read the dedicated article on api.video's blog: [Delegated Uploads](https://api.video/blog/tutorials/delegated-uploads/).
Using delegated upload tokens for authentication is best options when uploading from the client side. To know more about delegated upload token, read the dedicated article on api.video's blog: [Delegated Uploads](https://api.video/blog/tutorials/delegated-uploads).


| Option name | Mandatory | Type | Description |
Expand Down Expand Up @@ -297,7 +293,7 @@ On fail, the promise embeds the status code & error message returned by the API.
**Example**

```javascript
// ... uploader instantiation
// ... uploader instanciation

uploader.uploadPart(blob)
.catch((error) => console.log(error.status, error.message));
Expand All @@ -312,7 +308,7 @@ On fail, the promise embeds the status code & error message returned by the API.
**Example**

```javascript
// ... uploader instantiation
// ... uploader instanciation

uploader.uploadLastPart(blob)
.then((video) => console.log(video))
Expand All @@ -325,18 +321,24 @@ The onProgress() method let you defined an upload progress listener. It takes a
An onProgress event contains the following attributes:
- uploadedBytes (number): total number of bytes uploaded for this upload
- totalBytes (number): total size of the file
- part (number): index of the part being uploaded

**Example**

```javascript
// ... uploader instantiation
// ... uploader instanciation

uploader.onProgress((event) => {
console.log(`total number of bytes uploaded for this upload: ${event.uploadedBytes}.`);
console.log(`total size of the file: ${event.totalBytes}.`);
console.log(`current part: ${event.part}.`);
});
```

#### `cancel()`

The cancel() method cancels the upload. It takes no parameter.

#### `onPlayable()`

The onPlayable() method let you defined a listener that will be called when the video is playable. It takes a callback function with one parameter: the `video` object returned by the API.
Expand All @@ -347,11 +349,16 @@ The onPlayable() method let you defined a listener that will be called when the
<div id="player-container"></div>

<script>
// ... uploader instantiation
// ... uploader instanciation
uploader.onPlayable((video) => {
// the video is playable, we can display the player
document.getElementById('player-container').innerHTML = v.assets.iframe;
});
</script>
```
```


## Static wrapper

For situations where managing object instances is impractical, consider using the [UploaderStaticWrapper](./doc/UploaderStaticWrapper.md) class, which offers static method equivalents for all functionalities.

0 comments on commit 50030bf

Please sign in to comment.