@bytescale/sdk 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
Files changed (35) hide show
  1. package/README.md +391 -48
  2. package/dist/browser/cjs/main.js +723 -589
  3. package/dist/node/cjs/main.js +640 -263
  4. package/dist/node/esm/main.mjs +640 -263
  5. package/dist/types/index.d.ts +1 -1
  6. package/dist/types/private/AuthSessionState.d.ts +25 -8
  7. package/dist/types/private/EnvChecker.d.ts +1 -1
  8. package/dist/types/private/Mutex.d.ts +1 -1
  9. package/dist/types/private/StreamUtils.d.ts +1 -0
  10. package/dist/types/private/UploadManagerBase.d.ts +6 -1
  11. package/dist/types/private/UploadManagerBrowserWorkerBase.d.ts +19 -0
  12. package/dist/types/private/UploadManagerFetchUtils.d.ts +8 -0
  13. package/dist/types/private/model/AuthManagerInterface.d.ts +22 -5
  14. package/dist/types/private/model/AuthSession.d.ts +2 -2
  15. package/dist/types/private/model/OnPartProgress.d.ts +1 -1
  16. package/dist/types/private/model/UploadSourceProcessed.d.ts +6 -1
  17. package/dist/types/public/browser/AuthManagerBrowser.d.ts +11 -6
  18. package/dist/types/public/browser/UploadManagerBrowser.d.ts +3 -12
  19. package/dist/types/public/node/AuthManagerNode.d.ts +8 -3
  20. package/dist/types/public/shared/CommonTypes.d.ts +0 -1
  21. package/dist/types/public/shared/UrlBuilder.d.ts +10 -11
  22. package/dist/types/public/shared/UrlBuilderTypes.d.ts +65 -71
  23. package/dist/types/public/shared/generated/apis/FileApi.d.ts +104 -3
  24. package/dist/types/public/shared/generated/apis/FolderApi.d.ts +0 -3
  25. package/dist/types/public/shared/generated/apis/JobApi.d.ts +0 -3
  26. package/dist/types/public/shared/generated/apis/UploadApi.d.ts +6 -3
  27. package/dist/types/public/shared/generated/models/index.d.ts +5 -7
  28. package/dist/types/public/shared/generated/runtime.d.ts +7 -5
  29. package/dist/types/public/worker/UploadManagerWorker.d.ts +8 -0
  30. package/dist/types/public/worker/index.d.ts +2 -0
  31. package/dist/worker/cjs/main.js +2578 -0
  32. package/dist/worker/esm/main.mjs +2578 -0
  33. package/package.json +7 -8
  34. package/tests/UploadManager.test.ts +0 -7
  35. package/tests/UrlBuilder.test.ts +60 -59
package/README.md CHANGED
@@ -1,76 +1,260 @@
1
- # Bytescale JavaScript SDK
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>
2
6
 
3
- The Bytescale JavaScript SDK allows you to quickly integrate your application with [Bytescale](https://www.bytescale.com).
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>
4
11
 
5
- Effortlessly upload, optimize, transform, and host your digital media assets.
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/>
52
+
53
+ <img alt="Bytescale JavaScript SDK Example" src="https://raw.githubusercontent.com/bytescale/bytescale-javascript-sdk/main/.github/assets/bytescale-javascript-sdk.png">
6
54
 
7
55
  ## Installation
8
56
 
57
+ #### For Node.js:
58
+
9
59
  ```bash
10
- npm install @bytescale/sdk
60
+ npm install @bytescale/sdk node-fetch
11
61
  ```
12
62
 
13
- Additional step for Node.js:
63
+ #### For Browsers:
14
64
 
15
65
  ```bash
16
- npm install node-fetch
66
+ npm install @bytescale/sdk
17
67
  ```
18
68
 
19
- ## Full Documentation
69
+ Or:
20
70
 
21
- **[Bytescale JavaScript SDK Full Documentation »](https://www.bytescale.com/docs/sdks/javascript)**
71
+ ```html
72
+ <script src="https://js.bytescale.com/sdk/v3"></script>
73
+ ```
22
74
 
23
- ## Quick Guide
75
+ ## Uploading Files
24
76
 
25
- - [Upload a File](#upload-a-file)
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)**
77
+ This library is isomorphic, which means you can upload files from Node.js, or the browser, or both.
31
78
 
32
- ### Upload a File
79
+ #### From Node.js:
33
80
 
34
81
  ```javascript
35
82
  import * as Bytescale from "@bytescale/sdk";
36
- import fetch from "node-fetch"; // Node.js only.
83
+ import nodeFetch from "node-fetch";
37
84
 
38
85
  const uploadManager = new Bytescale.UploadManager({
39
- fetchApi: fetch, // 'fetch as any' for TypeScript
40
- apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
86
+ fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
87
+ apiKey: "free" // Get API keys from: www.bytescale.com
41
88
  });
42
89
 
43
90
  uploadManager
44
91
  .upload({
45
- accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
46
- // Supported types for 'data' field:
92
+ // Supported types:
47
93
  // - String
48
94
  // - Blob
49
- // - File (i.e. from a DOM file input element)
95
+ // - ArrayBuffer
50
96
  // - Buffer
51
97
  // - ReadableStream (Node.js), e.g. fs.createReadStream("file.txt")
52
- data: "Example 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
+ // Reports progress: bytesTotal, bytesSent, progress.
114
+ // onProgress: ({ progress }) => console.log(progress),
115
+
116
+ // Controls multipart upload concurrency. Ignored if 'data' is a stream.
117
+ // maxConcurrentUploadParts: 4,
118
+
119
+ // Up to 2KB of arbitrary JSON.
120
+ // metadata: {
121
+ // productId: 60891
122
+ // },
123
+
124
+ // Up to 25 tags per file.
125
+ // tags: [
126
+ // "example_tag"
127
+ // ],
128
+
129
+ // About file paths:
130
+ // - Your API key's "file upload path" is used by default, and can be changed by editing the API key's settings.
131
+ // - You can override the API key's file upload path by specifying a path below.
132
+ // - You may use path variables (e.g. "{UTC_DAY}"): http://localhost:3201/docs/path-variables
133
+ // path: {
134
+ // folderPath: "/uploads/{UTC_YEAR}/{UTC_MONTH}/{UTC_DAY}",
135
+ // fileName: "{UTC_TIME_TOKEN_INVERSE}{UNIQUE_DIGITS_2}{ORIGINAL_FILE_EXT}"
136
+ // },
137
+
138
+ // Set to 'isCancelled = true' after invoking 'upload' to cancel the upload.
139
+ // cancellationToken: {
140
+ // isCancelled: false
141
+ // }
53
142
  })
54
143
  .then(
55
- uploadedFile => console.log(uploadedFile),
56
- error => console.error(error)
144
+ ({ fileUrl, filePath }) => {
145
+ // --------------------------------------------
146
+ // File successfully uploaded!
147
+ // --------------------------------------------
148
+ // The 'filePath' uniquely identifies the file,
149
+ // and is what you should save to your DB.
150
+ // --------------------------------------------
151
+ console.log(`File uploaded to: ${fileUrl}`);
152
+ },
153
+ error => console.error(`Error: ${error.message}`, error)
57
154
  );
58
155
  ```
59
156
 
60
- ### Download a File
157
+ #### From the Browser:
158
+
159
+ ```html
160
+ <html>
161
+ <head>
162
+ <script src="https://js.bytescale.com/sdk/v3"></script>
163
+ <script>
164
+ // import * as Bytescale from "@bytescale/sdk"
165
+ const uploadManager = new Bytescale.UploadManager({
166
+ apiKey: "free" // Get API keys from: www.bytescale.com
167
+ });
168
+
169
+ const onFileSelected = async event => {
170
+ const file = event.target.files[0];
171
+
172
+ try {
173
+ const { fileUrl, filePath } = await uploadManager.upload({
174
+ // Supported types:
175
+ // - String
176
+ // - Blob
177
+ // - ArrayBuffer
178
+ // - File (i.e. from a DOM file input element)
179
+ data: file
180
+
181
+ // ---------
182
+ // Optional:
183
+ // ---------
184
+
185
+ // Required if 'data' is a stream. (Not required for DOM file inputs, blobs, buffers, or strings.)
186
+ // size: 5098, // e.g. fs.statSync("file.txt").size
187
+
188
+ // Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)
189
+ // mime: "application/octet-stream",
190
+
191
+ // Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)
192
+ // originalFileName: "my_file.txt",
193
+
194
+ // Reports progress: bytesTotal, bytesSent, progress.
195
+ // onProgress: ({ progress }) => console.log(progress),
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 only.
248
+ import nodeFetch from "node-fetch"; // Only required for Node.js
65
249
 
66
250
  const fileApi = new Bytescale.FileApi({
67
- fetchApi: fetch, // 'fetch as any' for TypeScript
68
- apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
251
+ fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
252
+ apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
69
253
  });
70
254
 
71
255
  fileApi
72
256
  .downloadFile({
73
- accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
257
+ accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk"
74
258
  filePath: "/uploads/2022/12/25/hello_world.txt"
75
259
  })
76
260
  .then(response => response.text()) // .text() | .json() | .blob() | .stream()
@@ -80,24 +264,31 @@ fileApi
80
264
  );
81
265
  ```
82
266
 
83
- **Note:** you can also download files using: `https://upcdn.io/{accountId}/raw/{filePath}`
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
- ### Process a File
269
+ ## Processing Files
86
270
 
87
271
  ```javascript
88
272
  import * as Bytescale from "@bytescale/sdk";
89
- import fetch from "node-fetch"; // Node.js only.
273
+ import fetch from "node-fetch"; // Only required for Node.js
274
+ import fs from "fs";
90
275
 
91
276
  const fileApi = new Bytescale.FileApi({
92
- fetchApi: fetch, // 'fetch as any' for TypeScript
93
- apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
277
+ fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
278
+ apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
94
279
  });
95
280
 
96
281
  fileApi
97
282
  .processFile({
98
- accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
283
+ accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk"
99
284
  filePath: "/uploads/2022/12/25/image.jpg",
100
- transformation: "thumbnail" // Create transformations here: https://www.bytescale.com/dashboard/transformations
285
+
286
+ // See: https://www.bytescale.com/docs/image-processing-api
287
+ transformation: "image",
288
+ transformationParams: {
289
+ w: 800,
290
+ h: 600
291
+ }
101
292
  })
102
293
  .then(response => response.stream()) // .text() | .json() | .blob() | .stream()
103
294
  .then(
@@ -115,22 +306,22 @@ fileApi
115
306
  );
116
307
  ```
117
308
 
118
- **Note:** you can also process files using: `https://upcdn.io/{accountId}/{transformation}/{filePath}`
309
+ Use the [`UrlBuilder`](#urlbuilder) to get a URL to your file (if you need a URL instead of downloading the file).
119
310
 
120
- ### Get File Details
311
+ ## Get File Details
121
312
 
122
313
  ```javascript
123
314
  import * as Bytescale from "@bytescale/sdk";
124
- import fetch from "node-fetch"; // Node.js only.
315
+ import fetch from "node-fetch"; // Only required for Node.js
125
316
 
126
317
  const fileApi = new Bytescale.FileApi({
127
- fetchApi: fetch, // 'fetch as any' for TypeScript
128
- apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
318
+ fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
319
+ apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
129
320
  });
130
321
 
131
322
  fileApi
132
323
  .getFileDetails({
133
- accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
324
+ accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk"
134
325
  filePath: "/uploads/2022/12/25/image.jpg"
135
326
  })
136
327
  .then(
@@ -139,20 +330,20 @@ fileApi
139
330
  );
140
331
  ```
141
332
 
142
- ### List Folder
333
+ ## Listing Folders
143
334
 
144
335
  ```javascript
145
336
  import * as Bytescale from "@bytescale/sdk";
146
- import fetch from "node-fetch"; // Node.js only.
337
+ import fetch from "node-fetch"; // Only required for Node.js
147
338
 
148
339
  const folderApi = new Bytescale.FolderApi({
149
- fetchApi: fetch, // 'fetch as any' for TypeScript
150
- apiKey: "YOUR_BYTESCALE_API_KEY" // e.g. "secret_xxxxx"
340
+ fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
341
+ apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
151
342
  });
152
343
 
153
344
  folderApi
154
345
  .listFolder({
155
- accountId: "YOUR_UPLOAD_ACCOUNT_ID", // e.g. "W142hJk"
346
+ accountId: "YOUR_ACCOUNT_ID", // e.g. "W142hJk"
156
347
  folderPath: "/",
157
348
  recursive: false
158
349
  })
@@ -163,6 +354,158 @@ folderApi
163
354
  );
164
355
  ```
165
356
 
357
+ ## More Operations
358
+
359
+ For a complete list of operations, please see:
360
+
361
+ **[Bytescale JavaScript SDK Docs »](https://www.bytescale.com/docs/sdks/javascript)**
362
+
363
+ ## Authorization
364
+
365
+ The Bytescale JavaScript SDK supports two types of authorization:
366
+
367
+ ### API Keys
368
+
369
+ The Bytescale JavaScript SDK automatically adds the `apiKey` from the constructor to the `Authorization` header for all requests made via the SDK.
370
+
371
+ With API key auth, the requester has access to the resources available to the API key:
372
+
373
+ - Secret API keys (`secret_***`) have access to all API endpoints.
374
+
375
+ - 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.)
376
+
377
+ Each Public API Key and Secret API Key can have its read/write access limited to a subset of files/folders.
378
+
379
+ ### JWT Cookies
380
+
381
+ JWT cookies are optional.
382
+
383
+ 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.
384
+
385
+ 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.
386
+
387
+ _Note: when using JWT cookies to download files, the `?auth=true` query parameter must be added to the URL._
388
+
389
+ [Learn more about the `AuthManager` and JWT cookies »](https://www.bytescale.com/docs/authorization#jwt-cookie)
390
+
391
+ ## UrlBuilder
392
+
393
+ Use the `UrlBuilder` to make URLs for your uploaded files:
394
+
395
+ ```javascript
396
+ import { UrlBuilder } from "@bytescale/sdk";
397
+ ```
398
+
399
+ #### Raw Files
400
+
401
+ To get the URL for the uploaded image `/example.jpg` in its original form, use the following params:
402
+
403
+ ```javascript
404
+ // Returns: "https://upcdn.io/1234abc/raw/example.jpg"
405
+ UrlBuilder.url({
406
+ accountId: "1234abc",
407
+ filePath: "/example.jpg"
408
+ });
409
+ ```
410
+
411
+ #### Images
412
+
413
+ To resize the uploaded image `/example.jpg` to 800x600, use the following params:
414
+
415
+ ```javascript
416
+ // Returns: "https://upcdn.io/1234abc/image/example.jpg?w=800&h=600"
417
+ UrlBuilder.url({
418
+ accountId: "1234abc",
419
+ filePath: "/example.jpg",
420
+ options: {
421
+ transformation: "image",
422
+ transformationParams: {
423
+ w: 800,
424
+ h: 600
425
+ }
426
+ }
427
+ });
428
+ ```
429
+
430
+ [Image Processing API Docs »](https://www.bytescale.com/docs/image-processing-api)
431
+
432
+ #### Videos
433
+
434
+ To transcode the uploaded video `/example.mov` to MP4/H.264 in HD, use the following params:
435
+
436
+ ```javascript
437
+ // Returns: "https://upcdn.io/1234abc/video/example.mov?f=mp4-h264&h=1080"
438
+ UrlBuilder.url({
439
+ accountId: "1234abc",
440
+ filePath: "/example.mov",
441
+ options: {
442
+ transformation: "video",
443
+ transformationParams: {
444
+ f: "mp4-h264",
445
+ h: 1080
446
+ }
447
+ }
448
+ });
449
+ ```
450
+
451
+ [Video Processing API Docs »](https://www.bytescale.com/docs/video-processing-api)
452
+
453
+ #### Audio
454
+
455
+ To transcode the uploaded audio `/example.wav` to AAC in 192kbps, use the following params:
456
+
457
+ ```javascript
458
+ // Returns: "https://upcdn.io/1234abc/audio/example.wav?f=aac&br=192"
459
+ UrlBuilder.url({
460
+ accountId: "1234abc",
461
+ filePath: "/example.wav",
462
+ options: {
463
+ transformation: "audio",
464
+ transformationParams: {
465
+ f: "aac",
466
+ br: 192
467
+ }
468
+ }
469
+ });
470
+ ```
471
+
472
+ [Audio Processing API Docs »](https://www.bytescale.com/docs/audio-processing-api)
473
+
474
+ #### Archives
475
+
476
+ To extract the file `document.docx` from the uploaded ZIP file `/example.zip`, use the following params:
477
+
478
+ ```javascript
479
+ // Returns: "https://upcdn.io/1234abc/archive/example.zip?m=extract&artifact=/document.docx"
480
+ UrlBuilder.url({
481
+ accountId: "1234abc",
482
+ filePath: "/example.zip",
483
+ options: {
484
+ transformation: "archive",
485
+ transformationParams: {
486
+ m: "extract"
487
+ },
488
+ artifact: "/document.docx"
489
+ }
490
+ });
491
+ ```
492
+
493
+ [Archive Processing API Docs »](https://www.bytescale.com/docs/archive-processing-api)
494
+
495
+ ## 👋 Create your Bytescale Account
496
+
497
+ Bytescale is the best way to serve images, videos, and audio for web apps.
498
+
499
+ **[Create a Bytescale account »](https://www.bytescale.com/get-started)**
500
+
501
+ ## 🙋 Can I use my own storage?
502
+
503
+ Bytescale supports AWS S3, Cloudflare R2, Google Storage, DigitalOcean Spaces, and Bytescale Storage.
504
+
505
+ **[Bytescale Storage Docs »](https://www.bytescale.com/docs/storage/sources)**
506
+
507
+ **[Bytescale JavaScript SDK Docs »](https://www.bytescale.com/docs/sdks/javascript)**
508
+
166
509
  ## License
167
510
 
168
511
  [MIT](LICENSE)