@bytescale/sdk 3.0.0-alpha.1 → 3.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +374 -38
- package/dist/browser/cjs/main.js +464 -385
- package/dist/node/cjs/main.js +452 -104
- package/dist/node/esm/main.mjs +454 -106
- package/dist/types/private/AuthSessionState.d.ts +25 -8
- package/dist/types/private/UploadManagerBase.d.ts +1 -0
- package/dist/types/public/browser/AuthManagerBrowser.d.ts +1 -0
- package/dist/types/public/shared/CommonTypes.d.ts +0 -1
- package/dist/types/public/shared/UrlBuilder.d.ts +1 -0
- package/dist/types/public/shared/UrlBuilderTypes.d.ts +65 -65
- package/dist/types/public/shared/generated/apis/FileApi.d.ts +104 -3
- package/dist/types/public/shared/generated/apis/FolderApi.d.ts +0 -3
- package/dist/types/public/shared/generated/apis/JobApi.d.ts +0 -3
- package/dist/types/public/shared/generated/apis/UploadApi.d.ts +6 -3
- package/dist/types/public/shared/generated/models/index.d.ts +5 -7
- package/dist/types/public/shared/generated/runtime.d.ts +8 -6
- package/package.json +2 -6
- package/tests/UploadManager.test.ts +0 -7
- package/tests/UrlBuilder.test.ts +31 -36
package/README.md
CHANGED
|
@@ -1,67 +1,251 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<a href="https://www.bytescale.com/docs/sdks/javascript">
|
|
3
|
+
<img alt="Bytescale JavaScript SDK" width="557" height="67" src="https://raw.githubusercontent.com/bytescale/bytescale-javascript-sdk/main/.github/assets/bytescale-javascript-sdk.svg">
|
|
4
|
+
</a>
|
|
5
|
+
</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://www.npmjs.com/package/@bytescale/sdk">
|
|
9
|
+
<img src="https://img.shields.io/badge/%40bytescale%2Fsdk-npm-4ba0f6" />
|
|
10
|
+
</a>
|
|
11
|
+
|
|
12
|
+
<a href="https://github.com/bytescale/bytescale-javascript-sdk/actions/workflows/ci.yml">
|
|
13
|
+
<img src="https://img.shields.io/badge/build-passing-4ba0f6" />
|
|
14
|
+
</a>
|
|
15
|
+
|
|
16
|
+
<a href="https://github.com/bytescale/bytescale-javascript-sdk/">
|
|
17
|
+
<img src="https://img.shields.io/badge/gzipped-9%20kb-4ba0f6" />
|
|
18
|
+
</a>
|
|
19
|
+
|
|
20
|
+
<a href="https://www.npmjs.com/package/@bytescale/sdk">
|
|
21
|
+
<img src="https://img.shields.io/npm/dt/upload-js?color=%234ba0f6" />
|
|
22
|
+
</a>
|
|
23
|
+
<br/>
|
|
24
|
+
|
|
25
|
+
<a href="https://www.npmjs.com/package/@bytescale/sdk">
|
|
26
|
+
<img src="https://img.shields.io/badge/TypeScript-included-4ba0f6" />
|
|
27
|
+
</a>
|
|
28
|
+
|
|
29
|
+
<a href="https://github.com/bytescale/bytescale-javascript-sdk/actions/workflows/ci.yml">
|
|
30
|
+
<img src="https://img.shields.io/npms-io/maintenance-score/upload-js?color=4ba0f6" />
|
|
31
|
+
</a>
|
|
32
|
+
|
|
33
|
+
<a target="_blank" href="https://twitter.com/intent/tweet?text=This%20was%20a%20great%20find...%0A%0Ahttps%3A%2F%2Fgithub.com%2Fbytescale%2Fbytescale-javascript-sdk">
|
|
34
|
+
<img alt="Twitter URL" src="https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fbytescale%2Fbytescale-javascript-sdk" />
|
|
35
|
+
</a>
|
|
36
|
+
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<hr/>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<b>Bytescale is the developer platform for images, video, and audio.</b>
|
|
43
|
+
<br />
|
|
44
|
+
<br />
|
|
45
|
+
Use the Bytescale JavaScript SDK to upload, transform, and serve files at scale.
|
|
46
|
+
<br />
|
|
47
|
+
<br />
|
|
48
|
+
<a href="https://www.bytescale.com/docs/sdks/javascript" rel="nofollow"><b>Full SDK Documentation</b></a> • <a href="https://www.bytescale.com/docs/upload-widget" rel="nofollow">Upload Widget</a> • <a href="https://www.bytescale.com/docs/media-processing-apis" rel="nofollow">Media Processing APIs</a> • <a href="https://www.bytescale.com/docs/storage/sources" rel="nofollow">Storage</a> • <a href="https://www.bytescale.com/docs/cdn" rel="nofollow">CDN</a>
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
<hr/>
|
|
6
52
|
|
|
7
53
|
## Installation
|
|
8
54
|
|
|
55
|
+
#### For Node.js:
|
|
56
|
+
|
|
9
57
|
```bash
|
|
10
|
-
npm install @bytescale/sdk
|
|
58
|
+
npm install @bytescale/sdk node-fetch
|
|
11
59
|
```
|
|
12
60
|
|
|
13
|
-
|
|
61
|
+
#### For Browsers:
|
|
14
62
|
|
|
15
63
|
```bash
|
|
16
|
-
npm install
|
|
64
|
+
npm install @bytescale/sdk
|
|
17
65
|
```
|
|
18
66
|
|
|
19
|
-
|
|
67
|
+
Or:
|
|
20
68
|
|
|
21
|
-
|
|
69
|
+
```html
|
|
70
|
+
<script src="https://js.bytescale.com/sdk/v3"></script>
|
|
71
|
+
```
|
|
22
72
|
|
|
23
|
-
##
|
|
73
|
+
## Uploading Files
|
|
24
74
|
|
|
25
|
-
|
|
26
|
-
- [Download a File](#download-a-file)
|
|
27
|
-
- [Process a File](#process-a-file)
|
|
28
|
-
- [Get File Details](#get-file-details)
|
|
29
|
-
- [List Folder](#list-folder)
|
|
30
|
-
- **[See All Methods »](https://www.bytescale.com/docs/sdks/javascript)**
|
|
75
|
+
This library is isomorphic, which means you can upload files from Node.js, or the browser, or both.
|
|
31
76
|
|
|
32
|
-
|
|
77
|
+
#### From Node.js:
|
|
33
78
|
|
|
34
79
|
```javascript
|
|
35
80
|
import * as Bytescale from "@bytescale/sdk";
|
|
36
|
-
import fetch from "node-fetch";
|
|
81
|
+
import fetch from "node-fetch";
|
|
37
82
|
|
|
38
83
|
const uploadManager = new Bytescale.UploadManager({
|
|
39
|
-
fetchApi: fetch, // 'fetch as any'
|
|
40
|
-
apiKey: "
|
|
84
|
+
fetchApi: fetch, // or 'fetch as any' (please note: you must use 'node-fetch' as errors can occur with other implementations)
|
|
85
|
+
apiKey: "free" // Get API keys from: www.bytescale.com
|
|
41
86
|
});
|
|
42
87
|
|
|
43
88
|
uploadManager
|
|
44
89
|
.upload({
|
|
45
|
-
|
|
90
|
+
// ---------
|
|
91
|
+
// Required:
|
|
92
|
+
// ---------
|
|
93
|
+
|
|
46
94
|
// Supported types for 'data' field:
|
|
47
95
|
// - String
|
|
48
|
-
// - Blob
|
|
49
|
-
// - File (i.e. from a DOM file input element)
|
|
50
96
|
// - Buffer
|
|
51
97
|
// - ReadableStream (Node.js), e.g. fs.createReadStream("file.txt")
|
|
52
|
-
data: "
|
|
98
|
+
data: "Hello World",
|
|
99
|
+
|
|
100
|
+
// ---------
|
|
101
|
+
// Optional:
|
|
102
|
+
// ---------
|
|
103
|
+
|
|
104
|
+
// Required if 'data' is a stream.
|
|
105
|
+
// size: 5098, // e.g. fs.statSync("file.txt").size
|
|
106
|
+
|
|
107
|
+
// Required if 'data' is a stream, buffer, or string.
|
|
108
|
+
mime: "text/plain",
|
|
109
|
+
|
|
110
|
+
// Required if 'data' is a stream, buffer, or string.
|
|
111
|
+
originalFileName: "my_file.txt"
|
|
112
|
+
|
|
113
|
+
// Controls multipart upload concurrency. Ignored if 'data' is a stream.
|
|
114
|
+
// maxConcurrentUploadParts: 4,
|
|
115
|
+
|
|
116
|
+
// Up to 2KB of arbitrary JSON.
|
|
117
|
+
// metadata: {
|
|
118
|
+
// productId: 60891
|
|
119
|
+
// },
|
|
120
|
+
|
|
121
|
+
// Up to 25 tags per file.
|
|
122
|
+
// tags: [
|
|
123
|
+
// "example_tag"
|
|
124
|
+
// ],
|
|
125
|
+
|
|
126
|
+
// About file paths:
|
|
127
|
+
// - Your API key's "file upload path" is used by default, and can be changed by editing the API key's settings.
|
|
128
|
+
// - You can override the API key's file upload path by specifying a path below.
|
|
129
|
+
// - You may use path variables (e.g. "{UTC_DAY}"): http://localhost:3201/docs/path-variables
|
|
130
|
+
// path: {
|
|
131
|
+
// folderPath: "/uploads/{UTC_YEAR}/{UTC_MONTH}/{UTC_DAY}",
|
|
132
|
+
// fileName: "{UTC_TIME_TOKEN_INVERSE}{UNIQUE_DIGITS_2}{ORIGINAL_FILE_EXT}"
|
|
133
|
+
// },
|
|
134
|
+
|
|
135
|
+
// Set to 'isCancelled = true' after invoking 'upload' to cancel the upload.
|
|
136
|
+
// cancellationToken: {
|
|
137
|
+
// isCancelled: false
|
|
138
|
+
// }
|
|
53
139
|
})
|
|
54
140
|
.then(
|
|
55
|
-
|
|
56
|
-
|
|
141
|
+
({ fileUrl, filePath }) => {
|
|
142
|
+
// --------------------------------------------
|
|
143
|
+
// File successfully uploaded!
|
|
144
|
+
// --------------------------------------------
|
|
145
|
+
// The 'filePath' uniquely identifies the file,
|
|
146
|
+
// and is what you should save to your DB.
|
|
147
|
+
// --------------------------------------------
|
|
148
|
+
console.log(`File uploaded to: ${fileUrl}`);
|
|
149
|
+
},
|
|
150
|
+
error => console.error(`Error: ${error.message}`, error)
|
|
57
151
|
);
|
|
58
152
|
```
|
|
59
153
|
|
|
60
|
-
|
|
154
|
+
#### From the Browser:
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<html>
|
|
158
|
+
<head>
|
|
159
|
+
<script src="https://js.bytescale.com/sdk/v3"></script>
|
|
160
|
+
<script>
|
|
161
|
+
// import * as Bytescale from "@bytescale/sdk"
|
|
162
|
+
const uploadManager = new Bytescale.UploadManager({
|
|
163
|
+
apiKey: "YOUR_API_KEY" // e.g. "public_xxxxx"
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const onFileSelected = async event => {
|
|
167
|
+
const file = event.target.files[0];
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
const { fileUrl, filePath } = await uploadManager.upload({
|
|
171
|
+
// ---------
|
|
172
|
+
// Required:
|
|
173
|
+
// ---------
|
|
174
|
+
|
|
175
|
+
// Your account ID (e.g. "W142hJk")
|
|
176
|
+
accountId: "YOUR_ACCOUNT_ID",
|
|
177
|
+
|
|
178
|
+
// Supported types for 'data' field:
|
|
179
|
+
// - String
|
|
180
|
+
// - Blob
|
|
181
|
+
// - File (i.e. from a DOM file input element)
|
|
182
|
+
data: file
|
|
183
|
+
|
|
184
|
+
// ---------
|
|
185
|
+
// Optional:
|
|
186
|
+
// ---------
|
|
187
|
+
|
|
188
|
+
// Required if 'data' is a stream. (Not required for DOM file inputs, blobs, buffers, or strings.)
|
|
189
|
+
// size: 5098, // e.g. fs.statSync("file.txt").size
|
|
190
|
+
|
|
191
|
+
// Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)
|
|
192
|
+
// mime: "application/octet-stream",
|
|
193
|
+
|
|
194
|
+
// Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)
|
|
195
|
+
// originalFileName: "my_file.txt",
|
|
196
|
+
|
|
197
|
+
// Controls multipart upload concurrency. Ignored if 'data' is a stream.
|
|
198
|
+
// maxConcurrentUploadParts: 4,
|
|
199
|
+
|
|
200
|
+
// Up to 2KB of arbitrary JSON.
|
|
201
|
+
// metadata: {
|
|
202
|
+
// productId: 60891
|
|
203
|
+
// },
|
|
204
|
+
|
|
205
|
+
// Up to 25 tags per file.
|
|
206
|
+
// tags: [
|
|
207
|
+
// "example_tag"
|
|
208
|
+
// ],
|
|
209
|
+
|
|
210
|
+
// About file paths:
|
|
211
|
+
// - Your API key's "file upload path" is used by default, and can be changed by editing the API key's settings.
|
|
212
|
+
// - You can override the API key's file upload path by specifying a path below.
|
|
213
|
+
// - You may use path variables (e.g. "{UTC_DAY}"): http://localhost:3201/docs/path-variables
|
|
214
|
+
// path: {
|
|
215
|
+
// folderPath: "/uploads/{UTC_YEAR}/{UTC_MONTH}/{UTC_DAY}",
|
|
216
|
+
// fileName: "{UTC_TIME_TOKEN_INVERSE}{UNIQUE_DIGITS_2}{ORIGINAL_FILE_EXT}"
|
|
217
|
+
// },
|
|
218
|
+
|
|
219
|
+
// Set to 'isCancelled = true' after invoking 'upload' to cancel the upload.
|
|
220
|
+
// cancellationToken: {
|
|
221
|
+
// isCancelled: false
|
|
222
|
+
// }
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// --------------------------------------------
|
|
226
|
+
// File successfully uploaded!
|
|
227
|
+
// --------------------------------------------
|
|
228
|
+
// The 'filePath' uniquely identifies the file,
|
|
229
|
+
// and is what you should save to your API.
|
|
230
|
+
// --------------------------------------------
|
|
231
|
+
alert(`File uploaded:\n${fileUrl}`);
|
|
232
|
+
} catch (e) {
|
|
233
|
+
alert(`Error:\n${e.message}`);
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
</script>
|
|
237
|
+
</head>
|
|
238
|
+
<body>
|
|
239
|
+
<input type="file" onchange="onFileSelected(event)" />
|
|
240
|
+
</body>
|
|
241
|
+
</html>
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Downloading Files
|
|
61
245
|
|
|
62
246
|
```javascript
|
|
63
247
|
import * as Bytescale from "@bytescale/sdk";
|
|
64
|
-
import fetch from "node-fetch"; // Node.js
|
|
248
|
+
import fetch from "node-fetch"; // Only required for Node.js
|
|
65
249
|
|
|
66
250
|
const fileApi = new Bytescale.FileApi({
|
|
67
251
|
fetchApi: fetch, // 'fetch as any' for TypeScript
|
|
@@ -80,13 +264,13 @@ fileApi
|
|
|
80
264
|
);
|
|
81
265
|
```
|
|
82
266
|
|
|
83
|
-
|
|
267
|
+
Use the [`UrlBuilder`](#urlbuilder) to get a URL to your file (if you need a URL instead of downloading the file).
|
|
84
268
|
|
|
85
|
-
|
|
269
|
+
## Processing Files
|
|
86
270
|
|
|
87
271
|
```javascript
|
|
88
272
|
import * as Bytescale from "@bytescale/sdk";
|
|
89
|
-
import fetch from "node-fetch"; // Node.js
|
|
273
|
+
import fetch from "node-fetch"; // Only required for Node.js
|
|
90
274
|
|
|
91
275
|
const fileApi = new Bytescale.FileApi({
|
|
92
276
|
fetchApi: fetch, // 'fetch as any' for TypeScript
|
|
@@ -97,7 +281,13 @@ fileApi
|
|
|
97
281
|
.processFile({
|
|
98
282
|
accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
|
|
99
283
|
filePath: "/uploads/2022/12/25/image.jpg",
|
|
100
|
-
|
|
284
|
+
|
|
285
|
+
// See: https://www.bytescale.com/docs/image-processing-api
|
|
286
|
+
transformation: "image",
|
|
287
|
+
transformationParams: {
|
|
288
|
+
w: 800,
|
|
289
|
+
h: 600
|
|
290
|
+
}
|
|
101
291
|
})
|
|
102
292
|
.then(response => response.stream()) // .text() | .json() | .blob() | .stream()
|
|
103
293
|
.then(
|
|
@@ -115,13 +305,13 @@ fileApi
|
|
|
115
305
|
);
|
|
116
306
|
```
|
|
117
307
|
|
|
118
|
-
|
|
308
|
+
Use the [`UrlBuilder`](#urlbuilder) to get a URL to your file (if you need a URL instead of downloading the file).
|
|
119
309
|
|
|
120
|
-
|
|
310
|
+
## Get File Details
|
|
121
311
|
|
|
122
312
|
```javascript
|
|
123
313
|
import * as Bytescale from "@bytescale/sdk";
|
|
124
|
-
import fetch from "node-fetch"; // Node.js
|
|
314
|
+
import fetch from "node-fetch"; // Only required for Node.js
|
|
125
315
|
|
|
126
316
|
const fileApi = new Bytescale.FileApi({
|
|
127
317
|
fetchApi: fetch, // 'fetch as any' for TypeScript
|
|
@@ -139,11 +329,11 @@ fileApi
|
|
|
139
329
|
);
|
|
140
330
|
```
|
|
141
331
|
|
|
142
|
-
|
|
332
|
+
## Listing Folders
|
|
143
333
|
|
|
144
334
|
```javascript
|
|
145
335
|
import * as Bytescale from "@bytescale/sdk";
|
|
146
|
-
import fetch from "node-fetch"; // Node.js
|
|
336
|
+
import fetch from "node-fetch"; // Only required for Node.js
|
|
147
337
|
|
|
148
338
|
const folderApi = new Bytescale.FolderApi({
|
|
149
339
|
fetchApi: fetch, // 'fetch as any' for TypeScript
|
|
@@ -163,6 +353,152 @@ folderApi
|
|
|
163
353
|
);
|
|
164
354
|
```
|
|
165
355
|
|
|
356
|
+
## Authorization
|
|
357
|
+
|
|
358
|
+
The Bytescale JavaScript SDK supports two types of authorization:
|
|
359
|
+
|
|
360
|
+
### API Keys
|
|
361
|
+
|
|
362
|
+
The Bytescale JavaScript SDK automatically adds the `apiKey` from the constructor to the `Authorization` header for all requests made via the SDK.
|
|
363
|
+
|
|
364
|
+
With API key auth, the requester has access to the resources available to the API key:
|
|
365
|
+
|
|
366
|
+
- Secret API keys (`secret_***`) have access to all API endpoints.
|
|
367
|
+
|
|
368
|
+
- Public API keys (`public_***`) have access to file upload, file download, and file listing API endpoints. (File listing is disabled by default. This can be changed in the API key's settings.)
|
|
369
|
+
|
|
370
|
+
Each Public API Key and Secret API Key can have its read/write access limited to a subset of files/folders.
|
|
371
|
+
|
|
372
|
+
### JWT Cookies
|
|
373
|
+
|
|
374
|
+
JWT cookies are optional.
|
|
375
|
+
|
|
376
|
+
With JWT cookies, the user can download private files directly via the URL, as authorization is performed implicitly via a session cookie. This allows the browser to display private files in `<img>` and `<video>` elements.
|
|
377
|
+
|
|
378
|
+
With JWT cookies, the user can also perform API requests (e.g. file uploads) granted by the [JWT's payload](https://www.bytescale.com/docs/types/BytescaleJwt). This is because the Bytescale JavaScript SDK automatically injects the user's JWT into the `authorization-token` request header for all API requests, assuming the `AuthManager.beginAuthSession` method has been called.
|
|
379
|
+
|
|
380
|
+
_Note: when using JWT cookies to download files, the `?auth=true` query parameter must be added to the URL._
|
|
381
|
+
|
|
382
|
+
[Learn more about the `AuthManager` and JWT cookies »](https://www.bytescale.com/docs/authorization#jwt-cookie)
|
|
383
|
+
|
|
384
|
+
## UrlBuilder
|
|
385
|
+
|
|
386
|
+
Use the `UrlBuilder` to make URLs for your uploaded files:
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
import { UrlBuilder } from "@bytescale/sdk";
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### Raw Files
|
|
393
|
+
|
|
394
|
+
To get the URL for the uploaded image `/example.jpg` in its original form, use the following params:
|
|
395
|
+
|
|
396
|
+
```javascript
|
|
397
|
+
// Returns: "https://upcdn.io/1234abc/raw/example.jpg"
|
|
398
|
+
new UrlBuilder().url({
|
|
399
|
+
accountId: "1234abc",
|
|
400
|
+
filePath: "/example.jpg"
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
#### Images
|
|
405
|
+
|
|
406
|
+
To resize the uploaded image `/example.jpg` to 800x600, use the following params:
|
|
407
|
+
|
|
408
|
+
```javascript
|
|
409
|
+
// Returns: "https://upcdn.io/1234abc/image/example.jpg?w=800&h=600"
|
|
410
|
+
new UrlBuilder().url({
|
|
411
|
+
accountId: "1234abc",
|
|
412
|
+
filePath: "/example.jpg",
|
|
413
|
+
options: {
|
|
414
|
+
transformation: "image",
|
|
415
|
+
transformationParams: {
|
|
416
|
+
w: 800,
|
|
417
|
+
h: 600
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
[Image Processing API Docs »](https://www.bytescale.com/docs/image-processing-api)
|
|
424
|
+
|
|
425
|
+
#### Videos
|
|
426
|
+
|
|
427
|
+
To transcode the uploaded video `/example.mov` to MP4/H.264 in HD, use the following params:
|
|
428
|
+
|
|
429
|
+
```javascript
|
|
430
|
+
// Returns: "https://upcdn.io/1234abc/video/example.mov?f=mp4-h264&h=1080"
|
|
431
|
+
new UrlBuilder().url({
|
|
432
|
+
accountId: "1234abc",
|
|
433
|
+
filePath: "/example.mov",
|
|
434
|
+
options: {
|
|
435
|
+
transformation: "video",
|
|
436
|
+
transformationParams: {
|
|
437
|
+
f: "mp4-h264",
|
|
438
|
+
h: 1080
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
[Video Processing API Docs »](https://www.bytescale.com/docs/video-processing-api)
|
|
445
|
+
|
|
446
|
+
#### Audio
|
|
447
|
+
|
|
448
|
+
To transcode the uploaded audio `/example.wav` to AAC in 192kbps, use the following params:
|
|
449
|
+
|
|
450
|
+
```javascript
|
|
451
|
+
// Returns: "https://upcdn.io/1234abc/audio/example.wav?f=aac&br=192"
|
|
452
|
+
new UrlBuilder().url({
|
|
453
|
+
accountId: "1234abc",
|
|
454
|
+
filePath: "/example.wav",
|
|
455
|
+
options: {
|
|
456
|
+
transformation: "audio",
|
|
457
|
+
transformationParams: {
|
|
458
|
+
f: "aac",
|
|
459
|
+
br: 192
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
[Audio Processing API Docs »](https://www.bytescale.com/docs/audio-processing-api)
|
|
466
|
+
|
|
467
|
+
#### Archives
|
|
468
|
+
|
|
469
|
+
To extract the file `document.docx` from the uploaded ZIP file `/example.zip`, use the following params:
|
|
470
|
+
|
|
471
|
+
```javascript
|
|
472
|
+
// Returns: "https://upcdn.io/1234abc/archive/example.zip?m=extract&artifact=/document.docx"
|
|
473
|
+
new UrlBuilder().url({
|
|
474
|
+
accountId: "1234abc",
|
|
475
|
+
filePath: "/example.zip",
|
|
476
|
+
options: {
|
|
477
|
+
transformation: "archive",
|
|
478
|
+
transformationParams: {
|
|
479
|
+
m: "extract"
|
|
480
|
+
},
|
|
481
|
+
artifact: "/document.docx"
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
[Archive Processing API Docs »](https://www.bytescale.com/docs/archive-processing-api)
|
|
487
|
+
|
|
488
|
+
## 👋 Create your Bytescale Account
|
|
489
|
+
|
|
490
|
+
Bytescale is the best way to serve images, videos, and audio for web apps.
|
|
491
|
+
|
|
492
|
+
**[Create a Bytescale account »](https://www.bytescale.com/get-started)**
|
|
493
|
+
|
|
494
|
+
## 🙋 Can I use my own storage?
|
|
495
|
+
|
|
496
|
+
Bytescale supports AWS S3, Cloudflare R2, Google Storage, DigitalOcean Spaces, and Bytescale Storage.
|
|
497
|
+
|
|
498
|
+
**[Bytescale Storage Docs »](https://www.bytescale.com/docs/storage/sources)**
|
|
499
|
+
|
|
500
|
+
**[Bytescale JavaScript SDK Docs »](https://www.bytescale.com/docs/sdks/javascript)**
|
|
501
|
+
|
|
166
502
|
## License
|
|
167
503
|
|
|
168
504
|
[MIT](LICENSE)
|