@uploadcare/upload-client 2.0.0-alpha.6 → 2.0.0

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 CHANGED
@@ -42,7 +42,7 @@ providing the necessary settings. Specifying `YOUR_PUBLIC_KEY` is mandatory: it
42
42
  points to the specific Uploadcare project:
43
43
 
44
44
  ```javascript
45
- import UploadClient from '@uploadcare/upload-client'
45
+ import { UploadClient } from '@uploadcare/upload-client'
46
46
 
47
47
  const client = new UploadClient({ publicKey: 'YOUR_PUBLIC_KEY' })
48
48
  ```
@@ -94,10 +94,10 @@ You can cancel file uploading and track this event:
94
94
 
95
95
  ```javascript
96
96
  const fileUUID = 'edfdf045-34c0-4087-bbdd-e3834921f890'
97
- const controller = new CancelController()
97
+ const abortController = new AbortController()
98
98
 
99
99
  client
100
- .uploadFile(fileUUID, { cancel: controller })
100
+ .uploadFile(fileUUID, { signal: abortController })
101
101
  .then(file => console.log(file.uuid))
102
102
  .catch(error => {
103
103
  if (error.isCancel) {
@@ -106,7 +106,7 @@ client
106
106
  })
107
107
 
108
108
  // Cancel uploading
109
- controller.cancel()
109
+ abortController.abort()
110
110
  ```
111
111
 
112
112
  List of all available `UploadClient` API methods:
@@ -163,17 +163,30 @@ interface UploadClient {
163
163
  }
164
164
  ```
165
165
 
166
+ You can import only needed methods directly, without `UploadClient` wrapper:
167
+
168
+ ```javascript
169
+ import {
170
+ uploadFile,
171
+ uploadFromUrl,
172
+ uploadBase,
173
+ uploadFromUploaded,
174
+ uploadMultipart,
175
+ uploadFileGroup
176
+ } from '@uploadcare/upload-client'
177
+ ```
178
+
166
179
  ### Low-Level API
167
180
 
168
181
  Also, you can use low-level wrappers to call the API endpoints directly:
169
182
 
170
183
  ```javascript
171
- import { base, CancelController } from '@uploadcare/upload-client'
184
+ import { base, AbortController } from '@uploadcare/upload-client'
172
185
 
173
186
  const onProgress = ({ value }) => console.log(value)
174
- const cancelController = new CancelController()
187
+ const abortController = new AbortController()
175
188
 
176
- base(fileData, { onProgress, cancel: cancelController }) // fileData must be `Blob` or `File` or `Buffer`
189
+ base(fileData, { onProgress, signal: abortController }) // fileData must be `Blob` or `File` or `Buffer`
177
190
  .then(data => console.log(data.file))
178
191
  .catch(error => {
179
192
  if (error.isCancel) {
@@ -182,7 +195,7 @@ base(fileData, { onProgress, cancel: cancelController }) // fileData must be `Bl
182
195
  })
183
196
 
184
197
  // Also you can cancel upload:
185
- cancelController.cancel()
198
+ abortController.abort()
186
199
  ```
187
200
 
188
201
  List of all available API methods:
@@ -290,7 +303,19 @@ of `API secret key` and `secureExpire`.
290
303
 
291
304
  Stands for the Unix time to which the signature is valid, e.g., `1454902434`.
292
305
 
293
- #### `integration: string`
306
+ #### `integration: string | CustomUserAgentFn`
307
+
308
+ ```typescript
309
+ type CustomUserAgentOptions = {
310
+ publicKey: string
311
+ libraryName: string
312
+ libraryVersion: string
313
+ languageName: string
314
+ integration?: string
315
+ }
316
+
317
+ type CustomUserAgentFn = (options: CustomUserAgentOptions) => string
318
+ ```
294
319
 
295
320
  `X-UC-User-Agent` header value.
296
321
 
@@ -372,7 +397,7 @@ npm run test
372
397
  By default, tests runs with mock server, but you can run tests with
373
398
  production environment.
374
399
 
375
- Run test on production servers:
400
+ Run test on production servers:
376
401
 
377
402
  ```bash
378
403
  npm run test:production