Skip to content

Commit e86ad7e

Browse files
Merge pull request #41 from apivideo/stream-uploads
Stream uploads
2 parents b3790ce + 997b01a commit e86ad7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+583
-375
lines changed

CoC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ For answers to common questions about this code of conduct, see the FAQ at
130130
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131131
[Mozilla CoC]: https://github.com/mozilla/diversity
132132
[FAQ]: https://www.contributor-covenant.org/faq
133-
[translations]: https://www.contributor-covenant.org/translations
133+
[translations]: https://www.contributor-covenant.org/translations

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ Method | HTTP request | Description
212212
## API Models
213213

214214
- [AccessToken](doc/model/AccessToken.md)
215-
- [Account](doc/model/Account.md)
216-
- [AccountQuota](doc/model/AccountQuota.md)
217215
- [AuthenticatePayload](doc/model/AuthenticatePayload.md)
218216
- [BadRequest](doc/model/BadRequest.md)
219217
- [BytesRange](doc/model/BytesRange.md)

doc/api/RawStatisticsApi.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Method | HTTP request | Description
2020
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });
2121

2222
const liveStreamId = 'vi4k0jvEUuaTdRAEjQ4Jfrgz'; // The unique identifier for the live stream you want to retrieve analytics for.
23-
const period = '2019-01-01'; // Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\"
23+
const period = '2019-01-01'; // Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\"
2424
const currentPage = '2'; // Choose the number of search results to return per page. Minimum value: 1
2525
const pageSize = '30'; // Results per page. Allowed values 1-100, default is 25.
2626

@@ -38,7 +38,7 @@ Method | HTTP request | Description
3838
Name | Type | Description | Notes
3939
------------- | ------------- | ------------- | -------------
4040
**liveStreamId** | **string**| The unique identifier for the live stream you want to retrieve analytics for. | [default to undefined]
41-
**period** | **string**| Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\" | [optional] [default to undefined]
41+
**period** | **string**| Period must have one of the following formats: - For a day : \"2018-01-01\", - For a week: \"2018-W01\", - For a month: \"2018-01\" - For a year: \"2018\" For a range period: - Date range: \"2018-01-01/2018-01-15\" | [optional] [default to undefined]
4242
**currentPage** | **number**| Choose the number of search results to return per page. Minimum value: 1 | [optional] [default to 1]
4343
**pageSize** | **number**| Results per page. Allowed values 1-100, default is 25. | [optional] [default to 25]
4444

@@ -112,8 +112,8 @@ Name | Type | Description | Notes
112112
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });
113113

114114
const videoId = 'vi4k0jvEUuaTdRAEjQ4Prklg'; // The unique identifier for the video you want to retrieve session information for.
115-
const period = 'period_example'; // Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15
116-
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with.
115+
const period = 'period_example'; // Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15
116+
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Metadata and [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) filter. Send an array of key value pairs you want to filter sessios with.
117117
const currentPage = '2'; // Choose the number of search results to return per page. Minimum value: 1
118118
const pageSize = '30'; // Results per page. Allowed values 1-100, default is 25.
119119

@@ -131,8 +131,8 @@ Name | Type | Description | Notes
131131
Name | Type | Description | Notes
132132
------------- | ------------- | ------------- | -------------
133133
**videoId** | **string**| The unique identifier for the video you want to retrieve session information for. | [default to undefined]
134-
**period** | **string**| Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 | [optional] [default to undefined]
135-
**metadata** | **{ [key: string]: string; }**| Metadata and Dynamic Metadata filter. Send an array of key value pairs you want to filter sessios with. | [optional]
134+
**period** | **string**| Period must have one of the following formats: - For a day : 2018-01-01, - For a week: 2018-W01, - For a month: 2018-01 - For a year: 2018 For a range period: - Date range: 2018-01-01/2018-01-15 | [optional] [default to undefined]
135+
**metadata** | **{ [key: string]: string; }**| Metadata and [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) filter. Send an array of key value pairs you want to filter sessios with. | [optional]
136136
**currentPage** | **number**| Choose the number of search results to return per page. Minimum value: 1 | [optional] [default to 1]
137137
**pageSize** | **number**| Results per page. Allowed values 1-100, default is 25. | [optional] [default to 25]
138138

doc/api/UploadTokensApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Name | Type | Description | Notes
149149
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });
150150

151151
const tokenCreationPayload = {
152-
ttl: 56, // Time in seconds that the token will be active. A value of 0 means that the token has no expiration date. The default is to have no expiration.
152+
ttl: 56, // Time in seconds that the token will be active. A value of 0 means that the token has no exipration date. The default is to have no expiration.
153153
};
154154

155155
// UploadToken

doc/api/VideosApi.md

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Name | Type | Description | Notes
151151

152152
const title = 'My Video.mp4'; // The title of a specific video you want to find. The search will match exactly to what term you provide and return any videos that contain the same term as part of their titles.
153153
const tags = '["captions", "dialogue"]'; // A tag is a category you create and apply to videos. You can search for videos with particular tags by listing one or more here. Only videos that have all the tags you list will be returned.
154-
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter.
154+
const metadata = 'metadata[Author]=John Doe&metadata[Format]=Tutorial'; // Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair.
155155
const description = 'New Zealand'; // If you described a video with a term or sentence, you can add it here to return videos containing this string.
156156
const liveStreamId = 'li400mYKSgQ6xs7taUeSaEKr'; // If you know the ID for a live stream, you can retrieve the stream by adding the ID for it here.
157157
const sortBy = 'publishedAt'; // Allowed: publishedAt, title. You can search by the time videos were published at, or by title.
@@ -174,7 +174,7 @@ Name | Type | Description | Notes
174174
------------- | ------------- | ------------- | -------------
175175
**title** | **string**| The title of a specific video you want to find. The search will match exactly to what term you provide and return any videos that contain the same term as part of their titles. | [optional] [default to undefined]
176176
**tags** | **Array<string>**| A tag is a category you create and apply to videos. You can search for videos with particular tags by listing one or more here. Only videos that have all the tags you list will be returned. | [optional]
177-
**metadata** | **{ [key: string]: string; }**| Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. | [optional]
177+
**metadata** | **{ [key: string]: string; }**| Videos can be tagged with metadata tags in key:value pairs. You can search for videos with specific key value pairs using this parameter. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair. | [optional]
178178
**description** | **string**| If you described a video with a term or sentence, you can add it here to return videos containing this string. | [optional] [default to undefined]
179179
**liveStreamId** | **string**| If you know the ID for a live stream, you can retrieve the stream by adding the ID for it here. | [optional] [default to undefined]
180180
**sortBy** | **string**| Allowed: publishedAt, title. You can search by the time videos were published at, or by title. | [optional] [default to undefined]
@@ -211,11 +211,11 @@ Name | Type | Description | Notes
211211
playerId: "pl4k0jvEUuaTdRAEjQ4Jfrgz", // The unique ID for the player you want to associate with your video.
212212
title: "title_example", // The title you want to use for your video.
213213
description: "A film about good books.", // A brief description of the video.
214-
_public: true, // Whether the video is publicly available or not. False means it is set to private.
214+
_public: true, // Whether the video is publicly available or not. False means it is set to private. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos).
215215
panoramic: false, // Whether the video is a 360 degree or immersive video.
216216
mp4Support: true, // Whether the player supports the mp4 format.
217217
tags: ["maths", "string theory", "video"], // A list of terms or words you want to tag the video with. Make sure the list includes all the tags you want as whatever you send in this list will overwrite the existing list for the video.
218-
metadata: null, // A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video.
218+
metadata: null, // A list (array) of dictionaries where each dictionary contains a key value pair that describes the video. As with tags, you must send the complete list of metadata you want as whatever you send here will overwrite the existing metadata for the video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair.
219219
};
220220

221221
// Video
@@ -261,7 +261,7 @@ Name | Type | Description | Notes
261261

262262
const videoId = 'vi4k0jvEUuaTdRAEjQ4Jfrgz'; // Unique identifier of the video you want to add a thumbnail to, where you use a section of your video as the thumbnail.
263263
const videoThumbnailPickPayload = {
264-
timecode: "timecode_example", // Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen.
264+
timecode: "timecode_example", // Frame in video to be used as a placeholder before the video plays. Example: '\"00:01:00.000\" for 1 minute into the video.' Valid Patterns: \"hh:mm:ss.ms\" \"hh:mm:ss:frameNumber\" \"124\" (integer value is reported as seconds) If selection is out of range, \"00:00:00.00\" will be chosen.
265265
};
266266

267267
// Video
@@ -326,11 +326,37 @@ Name | Type | Description | Notes
326326

327327
### Upload chunks
328328

329-
Large files are broken into chunks for upload. You can control the size of the chunks using the `setUploadChunkSize()` of method of `ApiVideoClient` before uploading:
329+
Large files are broken into chunks for upload. You can control the size of the chunks using the `chunkSize` parameter when you instanciate the ApiVideoClient:
330330

331-
```java
332-
apiVideoClient.setUploadChunkSize(50*1024*1024); // use 50MB chunks
333-
apiVideoClient.videos().uploadWithUploadToken(token, file);
331+
```js
332+
const client = new ApiVideoClient({
333+
apiKey: "YOUR_API_TOKEN",
334+
chunkSize: 50 * 1024 * 1024, // 50mb chunks
335+
});
336+
```
337+
338+
### Progressive uploads
339+
340+
Progressive uploads make it possible to upload a video source "progressively," i.e., before knowing the total size of the video. This is done by sending chunks of the video source file sequentially.
341+
The last chunk is sent by calling a different method, so api.video knows that it is time to reassemble the different chunks that were received.
342+
343+
```js
344+
(async () => {
345+
try {
346+
const client = new ApiVideoClient();
347+
const token = 'to1tcmSFHeYY5KzyhOqVKMKb'; // The unique identifier for the token you want to use to upload a video.
348+
349+
const uploadSession = client.createUploadWithUploadTokenProgressiveSession(token);
350+
351+
await uploadSession.uploadPart('test/data/10m.mp4.part.a');
352+
await uploadSession.uploadPart('test/data/10m.mp4.part.b');
353+
const res = await uploadSession.uploadLastPart('test/data/10m.mp4.part.c'); // Video
354+
355+
console.log(result);
356+
} catch (e) {
357+
console.error(e);
358+
}
359+
})();
334360
```
335361

336362
### Return type
@@ -361,12 +387,12 @@ apiVideoClient.videos().uploadWithUploadToken(token, file);
361387
title: "Maths video", // The title of your new video.
362388
description: "A video about string theory.", // A brief description of your video.
363389
source: "https://www.myvideo.url.com/video.mp4", // If you add a video already on the web, this is where you enter the url for the video.
364-
_public: true, // Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view.
390+
_public: true, // Whether your video can be viewed by everyone, or requires authentication to see it. A setting of false will require a unique token for each view. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos).
365391
panoramic: false, // Indicates if your video is a 360/immersive video.
366392
mp4Support: true, // Enables mp4 version in addition to streamed version.
367393
playerId: "pl45KFKdlddgk654dspkze", // The unique identification number for your video player.
368394
tags: ["maths", "string theory", "video"], // A list of tags you want to use to describe your video.
369-
metadata: [{"key": "Author", "value": "John Doe"}], // A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. You can also just use the pairs as another way to tag and categorize your videos.
395+
metadata: [{"key": "Author", "value": "John Doe"}], // A list of key value pairs that you use to provide metadata for your video. These pairs can be made dynamic, allowing you to segment your audience. Read more on [dynamic metadata](https://api.video/blog/endpoints/dynamic-metadata).
370396
};
371397

372398
// Video
@@ -431,11 +457,39 @@ Name | Type | Description | Notes
431457

432458
### Upload chunks
433459

434-
Large files are broken into chunks for upload. You can control the size of the chunks using the `setUploadChunkSize()` of method of `ApiVideoClient` before uploading:
460+
Large files are broken into chunks for upload. You can control the size of the chunks using the `chunkSize` parameter when you instanciate the ApiVideoClient:
461+
462+
```js
463+
const client = new ApiVideoClient({
464+
apiKey: "YOUR_API_TOKEN",
465+
chunkSize: 50 * 1024 * 1024, // 50mb chunks
466+
});
467+
```
468+
469+
### Progressive uploads
470+
471+
Progressive uploads make it possible to upload a video source "progressively," i.e., before knowing the total size of the video. This is done by sending chunks of the video source file sequentially.
472+
The last chunk is sent by calling a different method, so api.video knows that it is time to reassemble the different chunks that were received.
473+
474+
```js
475+
(async () => {
476+
try {
477+
478+
const client = new ApiVideoClient({ apiKey: "YOUR_API_TOKEN" });
479+
480+
const videoId = 'vi4k0jvEUuaTdRAEjQ4Jfrgz'; // Enter the videoId you want to use to upload your video.
481+
482+
const uploadSession = client.createUploadProgressiveSession(videoId);
435483

436-
```java
437-
apiVideoClient.setUploadChunkSize(50*1024*1024); // use 50MB chunks
438-
apiVideoClient.videos().upload(videoId, file);
484+
await uploadSession.uploadPart('test/data/10m.mp4.part.a');
485+
await uploadSession.uploadPart('test/data/10m.mp4.part.b');
486+
const res = await uploadSession.uploadLastPart('test/data/10m.mp4.part.c'); // Video
487+
488+
console.log(result);
489+
} catch (e) {
490+
console.error(e);
491+
}
492+
})();
439493
```
440494

441495
### Return type

doc/model/Account.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

doc/model/AccountQuota.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

doc/model/TokenCreationPayload.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
8-
**ttl** | **number** | Time in seconds that the token will be active. A value of 0 means that the token has no expiration date. The default is to have no expiration. | [optional]
8+
**ttl** | **number** | Time in seconds that the token will be active. A value of 0 means that the token has no exipration date. The default is to have no expiration. | [optional]
99

1010

1111

0 commit comments

Comments
 (0)