You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<h1align="center">api.video typescript video uploader</h1>
@@ -7,7 +8,7 @@
7
8
8
9
[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.
-[Using a delegated upload token (recommended):](#using-a-delegated-upload-token-recommended-1)
36
37
-[Using an access token (discouraged):](#using-an-access-token-discouraged-1)
@@ -44,19 +45,32 @@
44
45
-[`onPlayable()`](#onplayable-1)
45
46
-[Static wrapper](#static-wrapper)
46
47
47
-
# Project description
48
+
<!--</documentation_excluded>-->
49
+
<!--<documentation_only>
50
+
---
51
+
title: api.video TypeScript video uploader
52
+
meta:
53
+
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.
54
+
---
55
+
56
+
# api.video TypeScript video uploader
57
+
58
+
[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.
59
+
60
+
</documentation_only>-->
61
+
## Project description
48
62
49
63
Typescript library to upload videos to api.video using delegated upload token (or usual access token) from the front-end.
50
64
51
65
It allows you to upload videos in two ways:
52
66
- standard upload: to send a whole video file in one go
53
67
- progressive upload: to send a video file by chunks, without needing to know the final size of the video file
54
68
55
-
# Getting started
69
+
##Getting started
56
70
57
-
## Installation
71
+
###Installation
58
72
59
-
### Installation method #1: requirejs
73
+
####Installation method #1: requirejs
60
74
61
75
If you use requirejs you can add the library as a dependency to your project with
62
76
@@ -82,7 +96,7 @@ var uploader = new ProgressiveUploader({
82
96
});
83
97
```
84
98
85
-
### Installation method #2: typescript
99
+
####Installation method #2: typescript
86
100
87
101
If you use Typescript you can add the library as a dependency to your project with
88
102
@@ -109,7 +123,7 @@ const uploader = new ProgressiveUploader({
109
123
```
110
124
111
125
112
-
### Simple include in a javascript project
126
+
####Simple include in a javascript project
113
127
114
128
Include the library in your HTML file like so:
115
129
@@ -136,17 +150,17 @@ Then, once the `window.onload` event has been trigered, create your player using
136
150
</script>
137
151
```
138
152
139
-
# Documentation - Standard upload
153
+
##Documentation - Standard upload
140
154
141
-
##Instanciation
155
+
### Instantiation
142
156
143
-
### Options
157
+
####Options
144
158
145
-
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.
159
+
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.
146
160
147
-
#### Using a delegated upload token (recommended):
161
+
#####Using a delegated upload token (recommended):
148
162
149
-
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).
163
+
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/).
150
164
151
165
152
166
| Option name | Mandatory | Type | Description |
@@ -155,7 +169,7 @@ Using delegated upload tokens for authentication is best options when uploading
155
169
| videoId | no | string | id of an existing video |
156
170
|_common options (see bellow)_||||
157
171
158
-
#### Using an access token (discouraged):
172
+
#####Using an access token (discouraged):
159
173
160
174
**Warning**: be aware that exposing your access token client-side can lead to huge security issues. Use this method only if you know what you're doing :).
161
175
@@ -168,7 +182,7 @@ Using delegated upload tokens for authentication is best options when uploading
168
182
|_common options (see bellow)_||||
169
183
170
184
171
-
#### Using an API key (**strongly** discouraged):
185
+
#####Using an API key (**strongly** discouraged):
172
186
173
187
**Warning**: be aware that exposing your API key client-side can lead to huge security issues. Use this method only if you know what you're doing :).
174
188
@@ -180,7 +194,7 @@ Using delegated upload tokens for authentication is best options when uploading
180
194
|_common options (see bellow)_||||
181
195
182
196
183
-
#### Common options
197
+
#####Common options
184
198
185
199
186
200
| Option name | Mandatory | Type | Description |
@@ -194,7 +208,7 @@ Using delegated upload tokens for authentication is best options when uploading
194
208
| maxVideoDuration | no | number | maximum duration allowed for the file (in seconds) |
195
209
196
210
197
-
### Example
211
+
####Example
198
212
199
213
```javascript
200
214
constuploader=newVideoUploader({
@@ -205,9 +219,9 @@ Using delegated upload tokens for authentication is best options when uploading
205
219
});
206
220
```
207
221
208
-
## Methods
222
+
###Methods
209
223
210
-
### `upload()`
224
+
####`upload()`
211
225
212
226
The upload() method starts the upload. It takes no parameter. It returns a Promise that resolves once the file is uploaded. If an API call fails more than the specified number of retries, then the promise is rejected.
213
227
On success, the promise embeds the `video` object returned by the API.
@@ -216,14 +230,14 @@ On fail, the promise embeds the status code & error message returned by the API.
The onProgress() method let you defined an upload progress listener. It takes a callback function with one parameter: the onProgress events.
229
243
An onProgress event contains the following attributes:
@@ -234,15 +248,15 @@ An onProgress event contains the following attributes:
234
248
- currentChunk (number): index of the chunk being uploaded
235
249
- currentChunkUploadedBytes (number): number of bytes uploaded for the current chunk
236
250
237
-
### `cancel()`
251
+
####`cancel()`
238
252
239
253
The cancel() method cancels the upload. It takes no parameter.
240
254
241
255
242
256
**Example**
243
257
244
258
```javascript
245
-
// ... uploader instanciation
259
+
// ... uploader instantiation
246
260
247
261
uploader.onProgress((event) => {
248
262
console.log(`total number of bytes uploaded for this upload: ${event.uploadedBytes}.`);
@@ -255,7 +269,7 @@ The cancel() method cancels the upload. It takes no parameter.
255
269
```
256
270
257
271
258
-
### `onPlayable()`
272
+
####`onPlayable()`
259
273
260
274
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.
261
275
@@ -265,7 +279,7 @@ The onPlayable() method let you defined a listener that will be called when the
265
279
<divid="player-container"></div>
266
280
267
281
<script>
268
-
// ... uploader instanciation
282
+
// ... uploader instantiation
269
283
270
284
uploader.onPlayable((video) => {
271
285
// the video is playable, we can display the player
@@ -274,18 +288,18 @@ The onPlayable() method let you defined a listener that will be called when the
274
288
</script>
275
289
```
276
290
277
-
# Documentation - Progressive upload
291
+
##Documentation - Progressive upload
278
292
279
293
280
-
##Instanciation
294
+
### Instantiation
281
295
282
-
### Options
296
+
####Options
283
297
284
-
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.
298
+
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.
285
299
286
-
#### Using a delegated upload token (recommended):
300
+
#####Using a delegated upload token (recommended):
287
301
288
-
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).
302
+
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/).
289
303
290
304
291
305
| Option name | Mandatory | Type | Description |
@@ -294,7 +308,7 @@ Using delegated upload tokens for authentication is best options when uploading
294
308
| videoId | no | string | id of an existing video |
295
309
|_common options (see bellow)_||||
296
310
297
-
#### Using an access token (discouraged):
311
+
#####Using an access token (discouraged):
298
312
299
313
**Warning**: be aware that exposing your access token client-side can lead to huge security issues. Use this method only if you know what you're doing :).
300
314
@@ -306,7 +320,7 @@ Using delegated upload tokens for authentication is best options when uploading
306
320
|_common options (see bellow)_||||
307
321
308
322
309
-
#### Common options
323
+
#####Common options
310
324
311
325
312
326
| Option name | Mandatory | Type | Description |
@@ -318,7 +332,7 @@ Using delegated upload tokens for authentication is best options when uploading
318
332
| mergeSmallPartsBeforeUpload | no | boolean | if false, parts smaller than 5MB will not be merged before upload, resulting in an error (default: true) |
319
333
320
334
321
-
### Example
335
+
####Example
322
336
323
337
```javascript
324
338
constuploader=newProgressiveUploader({
@@ -327,9 +341,9 @@ Using delegated upload tokens for authentication is best options when uploading
327
341
});
328
342
```
329
343
330
-
## Methods
344
+
###Methods
331
345
332
-
### `uploadPart(file: Blob)`
346
+
####`uploadPart(file: Blob)`
333
347
334
348
The upload() method starts the upload. It takes no parameter. It returns a Promise that resolves once the file is uploaded. If an API call fails more than the specified number of retries, then the promise is rejected.
335
349
On success, the promise embeds the `video` object returned by the API.
@@ -338,13 +352,13 @@ On fail, the promise embeds the status code & error message returned by the API.
The upload() method starts the upload. It takes no parameter. It returns a Promise that resolves once the file is uploaded. If an API call fails more than the specified number of retries, then the promise is rejected.
350
364
On success, the promise embeds the `video` object returned by the API.
@@ -353,14 +367,14 @@ On fail, the promise embeds the status code & error message returned by the API.
The onProgress() method let you defined an upload progress listener. It takes a callback function with one parameter: the onProgress events.
366
380
An onProgress event contains the following attributes:
@@ -371,7 +385,7 @@ An onProgress event contains the following attributes:
371
385
**Example**
372
386
373
387
```javascript
374
-
// ... uploader instanciation
388
+
// ... uploader instantiation
375
389
376
390
uploader.onProgress((event) => {
377
391
console.log(`total number of bytes uploaded for this upload: ${event.uploadedBytes}.`);
@@ -380,11 +394,11 @@ An onProgress event contains the following attributes:
380
394
});
381
395
```
382
396
383
-
### `cancel()`
397
+
####`cancel()`
384
398
385
399
The cancel() method cancels the upload. It takes no parameter.
386
400
387
-
### `onPlayable()`
401
+
####`onPlayable()`
388
402
389
403
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.
390
404
@@ -394,7 +408,7 @@ The onPlayable() method let you defined a listener that will be called when the
394
408
<divid="player-container"></div>
395
409
396
410
<script>
397
-
// ... uploader instanciation
411
+
// ... uploader instantiation
398
412
399
413
uploader.onPlayable((video) => {
400
414
// the video is playable, we can display the player
@@ -404,6 +418,6 @@ The onPlayable() method let you defined a listener that will be called when the
404
418
```
405
419
406
420
407
-
# Static wrapper
421
+
##Static wrapper
408
422
409
-
For situations where managing object instances is impractical, consider using the [UploaderStaticWrapper](./doc/UploaderStaticWrapper.md) class, which offers static method equivalents for all functionalities.
423
+
For situations where managing object instances is impractical, consider using the [UploaderStaticWrapper](https://github.com/apivideo/api.video-typescript-uploader/blob/main/doc/UploaderStaticWrapper.md) class, which offers static method equivalents for all functionalities.
0 commit comments