Skip to content

Commit d7569ca

Browse files
Merge pull request #32 from apivideo/static-wrapper
Add static wrapper
2 parents 8615fb1 + b48b66b commit d7569ca

File tree

7 files changed

+417
-1
lines changed

7 files changed

+417
-1
lines changed

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tabWidth": 4,
3+
"useTabs": false,
4+
"printWidth": 120
5+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.1.6] - 2023-10-31
5+
- Add static wrapper
6+
47
## [1.1.5] - 2023-10-26
58
- Add cancel() methods
69
- Add part number in progressive upload onProgress()

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
- [`onProgress()`](#onprogress-1)
4343
- [`cancel()`](#cancel-1)
4444
- [`onPlayable()`](#onplayable-1)
45+
- [Static wrapper](#static-wrapper)
4546

4647
# Project description
4748

@@ -402,3 +403,7 @@ The onPlayable() method let you defined a listener that will be called when the
402403
</script>
403404
```
404405

406+
407+
# Static wrapper
408+
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.

doc/UploaderStaticWrapper.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Uploader static wrapper documentation
2+
3+
## Overview
4+
5+
The `UploaderStaticWrapper` class serves as a static interface to the underlying object-oriented uploader library.
6+
7+
This static abstraction is particularly beneficial in contexts where direct object manipulation can be challenging, such as when working within cross-platform frameworks like Flutter or React Native, or in no-code solutions.
8+
9+
By providing a suite of static methods, `UploaderStaticWrapper` allows developers to leverage the power of the library without the complexity of handling instances or managing object lifecycles.
10+
11+
This approach simplifies integration, making it more accessible for a wider range of development environments where traditional object-oriented paradigms are less suitable or harder to implement.
12+
13+
## Common functions
14+
15+
### `UploaderStaticWrapper.setApplicationName(name: string, version: string)`
16+
17+
Sets the application name and version for the SDK.
18+
19+
- **Parameters:**
20+
- `name: string` - The name of the application using the SDK.
21+
- `version: string` - The version of the application.
22+
23+
### `UploaderStaticWrapper.setChunkSize(chunkSize: number)`
24+
25+
Sets the chunk size for the video upload.
26+
27+
- **Parameters:**
28+
- `chunkSize: number` - The size of each chunk in bytes.
29+
30+
31+
### `UploaderStaticWrapper.cancelAll()`
32+
33+
Cancels all ongoing uploads, both progressive and standard.
34+
35+
36+
## Standard uploads functions
37+
38+
39+
### `UploaderStaticWrapper.uploadWithUploadToken(blob: Blob, uploadToken: string, videoName: string, onProgress: (event: number) => void, videoId?: string)`
40+
41+
Uploads a video with an upload token.
42+
43+
- **Parameters:**
44+
- `blob: Blob` - The video file to be uploaded.
45+
- `uploadToken: string` - The upload token provided by the backend.
46+
- `videoName: string` - The name of the video.
47+
- `onProgress: (event: number) => void` - The callback to call on progress updates.
48+
- `videoId?: string` - The ID of the video to be uploaded (optional).
49+
50+
- **Returns:**
51+
- `Promise<string>` - A promise resolving to a JSON representation of the `VideoUploadResponse` object.
52+
53+
### `UploaderStaticWrapper.uploadWithApiKey(blob: Blob, apiKey: string, onProgress: (event: number) => void, videoId: string)`
54+
55+
Uploads a video with an API key.
56+
57+
- **Parameters:**
58+
- `blob: Blob` - The video file to be uploaded.
59+
- `apiKey: string` - The API key provided by the backend.
60+
- `onProgress: (event: number) => void` - The callback to call on progress updates.
61+
- `videoId: string` - The ID of the video to be uploaded (optional).
62+
63+
- **Returns:**
64+
- `Promise<string>` - A promise resolving to a JSON representation of the `VideoUploadResponse` object.
65+
66+
## Progressive uploads functions
67+
68+
### `UploaderStaticWrapper.createProgressiveUploadWithUploadTokenSession(sessionId: string, uploadToken: string, videoId: string)`
69+
70+
Creates a new progressive upload session with an upload token.
71+
72+
- **Parameters:**
73+
- `sessionId: string` - The unique session identifier.
74+
- `uploadToken: string` - The upload token provided by the backend.
75+
- `videoId: string` - The ID of the video to be uploaded.
76+
77+
### `UploaderStaticWrapper.createProgressiveUploadWithApiKeySession(sessionId: string, apiKey: string, videoId: string)`
78+
79+
Creates a new progressive upload session with an API key.
80+
81+
- **Parameters:**
82+
- `sessionId: string` - The unique session identifier.
83+
- `apiKey: string` - The API key provided by the backend.
84+
- `videoId: string` - The ID of the video to be uploaded.
85+
86+
### `UploaderStaticWrapper.uploadPart(sessionId: string, blob: Blob, onProgress: (progress: number) => void)`
87+
88+
Uploads a part of a video in a progressive upload session.
89+
90+
- **Parameters:**
91+
- `sessionId: string` - The unique session identifier.
92+
- `blob: Blob` - The video part.
93+
- `onProgress: (progress: number) => void` - The callback to call on progress updates.
94+
95+
- **Returns:**
96+
- `Promise<string>` - A promise resolving to a JSON representation of the `VideoUploadResponse` object.
97+
-
98+
### `UploaderStaticWrapper.uploadLastPart(sessionId: string, blob: Blob, onProgress: (progress: number) => void)`
99+
100+
Uploads the last part of a video in a progressive upload session and finalizes the upload.
101+
102+
- **Parameters:**
103+
- `sessionId: string` - The unique session identifier.
104+
- `blob: Blob` - The video part.
105+
- `onProgress: (progress: number) => void` - The callback to call on progress updates.
106+
107+
- **Returns:**
108+
- `Promise<string>` - A promise resolving to a JSON representation of the `VideoUploadResponse` object.
109+
110+
### `UploaderStaticWrapper.disposeProgressiveUploadSession(sessionId: string)`
111+
112+
Disposes a progressive upload session by its ID.
113+
114+
- **Parameters:**
115+
- `sessionId: string` - The unique session identifier to dispose.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api.video/video-uploader",
3-
"version": "1.1.5",
3+
"version": "1.1.6",
44
"description": "api.video video uploader",
55
"repository": {
66
"type": "git",

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ import { VideoUploader } from "./video-uploader";
33
export { UploadProgressEvent, VideoUploader, VideoUploaderOptionsWithAccessToken, VideoUploaderOptionsWithUploadToken } from "./video-uploader";
44
export { ProgressiveUploadProgressEvent, ProgressiveUploader, ProgressiveUploaderOptionsWithAccessToken, ProgressiveUploaderOptionsWithUploadToken } from './progressive-video-uploader';
55
export { VideoUploadResponse, MIN_CHUNK_SIZE, MAX_CHUNK_SIZE } from './abstract-uploader';
6+
export { UploaderStaticWrapper } from './static-wrapper';

0 commit comments

Comments
 (0)