Détail du package

@uploadcare/upload-client

uploadcare172.6kMIT6.15.2

Library for work with Uploadcare Upload API

uploadcare, file, uploader, image

readme

Uploadcare Upload Client

This is an Uploadcare Upload API wrapper to work with Node.js and browser.

API Reference

Build Status NPM version GitHub release  Uploadcare stack on StackShare

Install

npm install @uploadcare/upload-client

Usage

High-Level API

To access the High-Level API, you need to create an instance of UploadClient providing the necessary settings. Specifying YOUR_PUBLIC_KEY is mandatory: it points to the specific Uploadcare project:

import { UploadClient } from '@uploadcare/upload-client'

const client = new UploadClient({ publicKey: 'YOUR_PUBLIC_KEY' })

Once the UploadClient instance is created, you can start using the wrapper to upload files from binary data:

client.uploadFile(fileData).then((file) => console.log(file.uuid))

Another option is uploading files from URL, via the uploadFile method:

const fileURL = 'https://example.com/file.jpg'

client.uploadFile(fileURL).then((file) => console.log(file.uuid))

You can also use the uploadFile method to get previously uploaded files via their UUIDs:

const fileUUID = 'edfdf045-34c0-4087-bbdd-e3834921f890'

client.uploadFile(fileUUID).then((file) => console.log(file.uuid))

You can track uploading progress:

const fileUUID = 'edfdf045-34c0-4087-bbdd-e3834921f890'
const onProgress = ({ isComputable, value }) => {
  console.log(isComputable, value)
}

client
  .uploadFile(fileUUID, { onProgress })
  .then((file) => console.log(file.uuid))

Note that isComputable flag can be false is some cases of uploading from the URL. If we can't calculate the file size, progress info will look like { isComputable: false } without a value. Successful uploading progress will be always { isComputable: true, value: 1 }.

You can cancel file uploading and track this event:

const fileUUID = 'edfdf045-34c0-4087-bbdd-e3834921f890'
const abortController = new AbortController()

client
  .uploadFile(fileUUID, { signal: abortController.signal })
  .then((file) => console.log(file.uuid))
  .catch((error) => {
    if (error.isCancel) {
      console.log(`File uploading was canceled.`)
    }
  })

// Cancel uploading
abortController.abort()

List of all available UploadClient API methods:

interface UploadClient {
  updateSettings(newSettings: Settings = {}): void

  getSettings(): Settings

  base(
    file: Blob | File | Buffer | ReactNativeAsset,
    options: BaseOptions
  ): Promise<BaseResponse>

  info(uuid: Uuid, options: InfoOptions): Promise<FileInfo>

  fromUrl(sourceUrl: Url, options: FromUrlOptions): Promise<FromUrlResponse>

  fromUrlStatus(
    token: Token,
    options: FromUrlStatusOptions
  ): Promise<FromUrlStatusResponse>

  group(uuids: Uuid[], options: GroupOptions): Promise<GroupInfo>

  groupInfo(id: GroupId, options: GroupInfoOptions): Promise<GroupInfo>

  multipartStart(
    size: number,
    options: MultipartStartOptions
  ): Promise<MultipartStartResponse>

  multipartUpload(
    part: Buffer | Blob,
    url: MultipartPart,
    options: MultipartUploadOptions
  ): Promise<MultipartUploadResponse>

  multipartComplete(
    uuid: Uuid,
    options: MultipartCompleteOptions
  ): Promise<FileInfo>

  uploadFile(
    data: Blob | File | Buffer | ReactNativeAsset | Url | Uuid,
    options: FileFromOptions
  ): Promise<UploadcareFile>

  uploadFileGroup(
    data: (Blob | File | Buffer | ReactNativeAsset)[] | Url[] | Uuid[],
    options: FileFromOptions & GroupFromOptions
  ): Promise<UploadcareGroup>
}

You can import only needed methods directly, without UploadClient wrapper:

import {
  uploadFile,
  uploadFromUrl,
  uploadDirect,
  uploadFromUploaded,
  uploadMultipart,
  uploadFileGroup
} from '@uploadcare/upload-client'

Low-Level API

Also, you can use low-level wrappers to call the API endpoints directly:

import { base } from '@uploadcare/upload-client'

const onProgress = ({ isComputable, value }) => console.log(isComputable, value)
const abortController = new AbortController()

base(fileData, { onProgress, signal: abortController.signal }) // fileData must be `Blob` or `File` or `Buffer`
  .then((data) => console.log(data.file))
  .catch((error) => {
    if (error.isCancel) {
      console.log(`File uploading was canceled.`)
    }
  })

// Also you can cancel upload:
abortController.abort()

List of all available API methods:

base(
  file: Blob | File | Buffer | ReactNativeAsset,
  options: BaseOptions
): Promise<BaseResponse>
info(uuid: Uuid, options: InfoOptions): Promise<FileInfo>
fromUrl(sourceUrl: Url, options: FromUrlOptions): Promise<FromUrlResponse>
fromUrlStatus(
  token: Token,
  options: FromUrlStatusOptions
): Promise<FromUrlStatusResponse>
group(uuids: Uuid[], options: GroupOptions): Promise<GroupInfo>
groupInfo(id: GroupId, options: GroupInfoOptions): Promise<GroupInfo>
multipartStart(
  size: number,
  options: MultipartStartOptions
): Promise<MultipartStartResponse>
multipartUpload(
  part: Buffer | Blob | File,
  url: MultipartPart,
  options: MultipartUploadOptions
): Promise<MultipartUploadResponse>
multipartComplete(
  uuid: Uuid,
  options: MultipartCompleteOptions
): Promise<FileInfo>

Settings

publicKey: string

The main use of a publicKey is to identify a target project for your uploads. It is required when using Upload API.

baseCDN: string

Defines your schema and CDN domain. Can be changed to one of the predefined values (https://ucarecdn.com/) or your custom CNAME.

Defaults to https://ucarecdn.com/.

baseURL: string

API base URL.

Defaults to https://upload.uploadcare.com

fileName: string

You can specify an original filename. It could useful when file input does not contain filename.

Defaults to original.

store: boolean

Forces files uploaded with UploadClient to be stored or not. For instance, you might want to turn this off when automatic file storing is enabled in your project, but you do not want to store files uploaded with a particular instance.

secureSignature: string

In case you enable signed uploads for your project, you’d need to provide the client with secureSignature and secureExpire params.

The secureSignature is an MD5 hex-encoded hash from a concatenation of API secret key and secureExpire.

secureExpire: string

Stands for the Unix time to which the signature is valid, e.g., 1454902434.

userAgent: string | CustomUserAgentFn

type CustomUserAgentOptions = {
  publicKey: string
  libraryName: string
  libraryVersion: string
  languageName: string
  integration?: string
}

type CustomUserAgentFn = (options: CustomUserAgentOptions) => string

X-UC-User-Agent header value.

Defaults to UploadcareUploadClient/${version}/${publicKey} (JavaScript; ${integration})

integration: string

Integration value passed to the X-UC-User-Agent header. May be overrided with the custom user agent string or function.

checkForUrlDuplicates: boolean

Runs the duplicate check and provides the immediate-download behavior.

saveUrlForRecurrentUploads: boolean

Provides the save/update URL behavior. The parameter can be used if you believe that the sourceUrl will be used more than once. Using the parameter also updates an existing reference with a new sourceUrl content.

source: string

Defines the upload source to use, can be set to local, url, etc.

jsonpCallback: string

Sets the name of your JSONP callback function to create files group from a set of files by using their UUIDs.

maxContentLength: number

maxContentLength defines the maximum allowed size (in bytes) of the HTTP response content.

Defaults to 52428800 bytes (50 MB).

retryThrottledRequestMaxTimes: number

Sets the maximum number of attempts to retry throttled requests.

Defaults to 1.

retryNetworkErrorMaxTimes: number

Sets the maximum number of attempts to retry requests that failed with a network error.

Defaults to 3.

The delay between attempts equals attempt number, i.e.

  • first attempt - 1 second delay
  • second attempt - 2 seconds delay
  • third attempt - 3 seconds delay
  • ...

multipartChunkSize: number

This option is only applicable when handling local files. Sets the multipart chunk size.

Defaults to 5242880 bytes (5 MB).

multipartMinFileSize: number

This option is only applicable when handling local files. Sets the multipart uploading file size threshold: larger files will be uploaded in the Multipart mode rather than via Direct Upload. The value is limited to the range from 10485760 (10 MB) to 104857600 (100 MB).

Defaults to 26214400 (25 MB).

multipartMinLastPartSize: number

This option is only applicable when handling local files. Set the minimum size of the last multipart part.

Defaults to 1048576 bytes (1 MB).

maxConcurrentRequests: number

Allows specifying the number of concurrent requests.

Defaults to 4.

contentType: string

This option is useful when file input does not contain content type.

Defaults to application/octet-stream.

metadata: Metadata

type Metadata = {
  [key: string]: string
}

Metadata is additional, arbitrary data, associated with uploaded file.

Non-string values will be converted to string. undefined values will be ignored.

See docs and REST API for details.

Uploading queue

If you're going to upload a lot of files at once, it's useful to do it in a queue. Otherwise, a large number of simultaneous requests can clog the internet channel and slow down the process.

To solve this problem, we provide a simple helper called Queue.

Here is an example of how to use it:

import { Queue, uploadFile } from '@uploadcare/upload-client'

// Create a queue with a limit of 10 concurrent requests.
const queue = new Queue(10)

// Create an array containing 50 files.
const files = [
  ...Array(50)
    .fill(0)
    .map((_, idx) => Buffer.from(`content-${idx}`))
]
const promises = files.map((file, idx) => {
  const fileName = `file-${idx}.txt`
  return queue
    .add(() =>
      uploadFile(file, {
        publicKey: 'YOUR_PUBLIC_KEY',
        contentType: 'plain/text',
        fileName
      })
    )
    .then((fileInfo) =>
      console.log(
        `"File "${fileName}" has been successfully uploaded! You can access it at the following URL: "${fileInfo.cdnUrl}"`
      )
    )
})

await Promise.all(promises)

console.log('Files have been successfully uploaded')

You can pass any function that returns a promise to queue.add, and it will be executed concurrently.

queue.add returns a promise that mimics the one passed in, meaning it will resolve or reject with the corresponding values.

If the functionality of the built-in Queue is not sufficient for you, you can use any other third-party, more functional solution.

React Native

Prepare

To be able to use @uploadcare/upload-client with React Native, you need to install react-native-url-polyfill.

To prevent Error: Cannot create URL for blob errors you need to configure your Android app schema to accept blobs - have a look at this pull request for an example: 5985d7e.

  1. Add the following code to the application section of your AndroidManifest.xml:
<provider
  android:name="com.facebook.react.modules.blob.BlobProvider"
  android:authorities="@string/blob_provider_authority"
  android:exported="false"
/>
  1. Add the following code to the android/app/src/main/res/values/strings.xml:
<resources>
  <string name="app_name">MY_REACT_NATIVE_APP_NAME</string>
  <string name="blob_provider_authority">com.detox.blob</string>
</resources>

Usage

You can use ReactNativeAsset as an input to the @uploadcare/upload-client like this:

type ReactNativeAsset = {
  uri: string
  type: string
  name?: string
}
const asset = { uri: 'URI_TO_FILE', name: 'file.txt', type: 'text/plain' }
uploadFile(asset, { publicKey: 'YOUR_PUBLIC_KEY' })

Or Blob like this:

const uri = 'URI_TO_FILE'
const blob = await fetch(uri).then((res) => res.blob())
uploadFile(blob, {
  publicKey: 'YOUR_PUBLIC_KEY',
  fileName: 'file.txt',
  contentType: 'text/plain'
})

Testing

npm run test

By default, tests runs with mock server, but you can run tests with production environment.

Run test on production servers:

npm run test:production

Run test with mock server (mock server starts automaticaly):

npm run test

Run mock server:

npm run mock:start

And then you can run test:

npm run test:jest

Security issues

If you think you ran into something in Uploadcare libraries that might have security implications, please hit us up at bugbounty@uploadcare.com or Hackerone.

We'll contact you personally in a short time to fix an issue through co-op and prior to any public disclosure.

Feedback

Issues and PRs are welcome. You can provide your feedback or drop us a support request at hello@uploadcare.com.

changelog

6.15.2 (2025-06-24)

Features

  • cname-prefix: add cname-prefix package (#534) (aa26175)
  • quality-insights: add quality-insights package (#533) (d2d3208)

6.14.3 (2025-02-25)

Bug Fixes

  • upload-client/multipart: set custom chunk size for multipart (#531) (13d4c84)

6.14.2 (2024-10-16)

Bug Fixes

  • upload-client/types: make UploadcareFile instance properties non-nullable cause they're can't be null actually (#529) (57c84a4)

6.14.1 (2024-03-08)

6.14.0 (2024-02-15)

Features

  • New package @uploadcare/image-shrink to reduce image size in the browser. See docs here.

6.13.0 (2024-02-06)

Bug Fixes

  • upload-client/group: use body to send query parameters (#511) (16f36f7)

Features

  • rest-client: export CancelError from the package (83f10c6)

6.12.1 (2024-01-12)

Bug Fixes

  • rest-client: send signed API requests with body in Firefox (#508) (6705984)

6.12.0 (2023-12-22)

Deprecations

  • UploadcareNetworkError is deprecated. Please use NetworkError instead.
  • UploadClientError is deprecated. Please use UploadError instead.

Features

  • api-client-utils: add base class UploadcareError for the errors (766586a)
  • rest-client: export UploadcareError and RestClientError from the package module (6432653)
  • upload-client: export CancelError from the package (7adf799)
  • upload-client: rename UploadcareNetworkError export to the NetworkError. UploadcareNetworkError is deprecated but still exported. (62cc416)
  • upload-client: rename UploadClientError export to the UploadError. UploadClientError is deprecated but still exported. (7c03c3d)

6.11.1 (2023-12-19)

Bug Fixes

  • upload-client/react-native: update bundle path (#504) (a0668c4)

6.11.0 (2023-11-15)

Features

  • rest-client: add AWS Rekognition Moderation addon (67a01dc)

6.10.0 (2023-11-14)

Features

  • rest-client/convert: add saveInGroup option to document conversion method (#499) (50720b7)

6.9.0 (2023-11-14)

Features

  • rest-client: add Document Info endpoint (7f0c528)

6.8.0 (2023-10-30)

Bug Fixes

  • types: imageInfo.datetimeOriginal could be null or string (#489) (4a717e1)

Features

  • upload-client: export isReadyPoll helper to wait for the file readiness (12cf9b1)

6.7.0 (2023-10-18)

Bug Fixes

  • upload-client/queue: don't use private class fields due to bad support of bundling tools (d61dc47)
  • upload-client/uploadFileGroup: do not request fileInfo before creating group from uuid (c3c8245)
  • upload-client/uploadFileGroup: support for the uuids with inline operations (c3c8245)
  • upload-client/UploadcareGroup: filter null values from the files property of group info (83c0b6c)
  • upload-client: fix package.json react-native field path (beee9c1)

Features

  • upload-client: add property defaultEffects to the UploadcareFile instance returned by uploadFileGroup method (abe39c4)

6.6.1 (2023-05-01)

Bug Fixes

  • upload-client: do not use buffer for browser-like bundles to prevent polyfilling by cdn (#484)

6.6.0 (2023-05-01)

Features

  • upload-client: add Queue helper to make queued uploads (#481) (aea890c)

6.5.1 (2023-04-25)

6.5.0 (2023-04-25)

Bug Fixes

  • set corresponding extension for the dynamic chunks (882741f)

Features

  • add CommonJS bundles (4aff9bc)
  • rest-client: export createSignature method (#472) (ccbb97a)

6.4.1 (2023-03-17)

Bug Fixes

  • upload-client/uploadFileGroup: accept checkForUrlDuplicates and saveUrlForRecurrentUploads (#470) (43e0ba9)

6.4.0 (2023-03-10)

BREAKING CHANGE without major bump

There will be no impact unless you are using the @uploadcare/signed-uploads package.

  • @uploadcare/signed-uploads: update generateSecureSignature signature - BREAKING CHANGE without major bump (97f7ebb)

6.3.0 (2023-03-09)

Features

  • add @uploadcare/signed-uploads package containing helper to generate signature for signed uploads (#466) (dd48ee4)

6.2.1 (2023-01-23)

Bug Fixes

  • upload-client: normalize output cdn url (#463) (cd37f4d)

6.2.0 (2023-01-20)

Bug Fixes

  • upload-client: send content-type header when uploading multipart (#461) (3a402a3)

Features

  • upload-client: accept auto as store value (#460) (e140644)

6.1.0 (2023-01-10)

Bug Fixes

  • upload-client: ensure that file name and type passed to the FormData (fe63607)

Features

  • upload-client: export all the types (d2bbd76)
  • upload-client: support react-native asset file input (f586f84)

6.0.0 (2022-12-07)

  • refactor(rest-client)!: merge document and video conversion methods into the two common ones - convert and conversionJobStatus (beb2bb6)
  • fix(rest-client)!: do not change case of the appdata field and its content (92d785d)
  • feat(rest-client)!: accept boolean or "auto" for the store option (440e228)

Features

  • api-client-utils: add timeout option to the poll (f27f25a)
  • rest-client: add addon job status polling (8f2aec7)
  • rest-client: add conversion api polling (41c6aa5)

BREAKING CHANGES

  • Methods convertVideo, convertDocument, videoConversionJobStatus and documentConversionJobStatus are removed. Please use convert and conversionJobStatus methods. Type of conversion (video or document) passed as type option.
  • Now appdata field is returned as-is, without kebab -> camel case conversion
  • string ("true", "false", "1", "0") values for the store option of convertVideo and convertDocument aren't accepted anymore. Please use boolean value or "auto". It's "auto" by default"

5.2.0 (2022-11-26)

Bug Fixes

  • rest-client: send user-agent instead of x-uc-user-agent header (#447) (759768a)
  • upload-client: read retry-after header instead of x-throttle-wait-seconds (81698df)

Features

  • rest-client: add pagination helpers (#450) (19f6d8f)
  • rest-client: retry requests on network errors (#449) (846d8fd)

5.1.2 (2022-11-24)

Bug Fixes

  • rest-client: pass-through outer headers when signing request with UploadcareSimpleAuthSchema (0c912e1)

5.1.1 (2022-10-28)

Bug Fixes

  • specify types path for the root export, fixes #436 (see PR #437)

Features

  • add separate exports for node, browser and react-native bundles. It's useful when you wanna explicitly import needed bundle instead of relying the bundler's choice (see PR #437)

5.1.0 (2022-09-13)

Features

  • rest-client: add executeAddon and addonExecutionStatus (5b7123f)

5.0.0 (2022-09-13)

  • refactor(upload-client)!: drop multipartMaxAttempts option (178436e)

Features

  • api-client-utils: add UploadcareNetworkError (0e917d2)
  • upload-client: add retryNetworkErrorMaxTimes option to specify retries count on network errors (400fedd)
  • upload-client: throw UploadcareNetworkError instead of Error (f7e3f55)

BREAKING CHANGES

  • option multipartMaxAttempts is dropped. Use retryNetworkErrorMaxTimes instead. It will affect all the requests, not only multipart uploads.

4.3.1 (2022-08-24)

Bug Fixes

4.3.0 (2022-07-20)

Features

  • export getUserAgent method from @uploadcare/api-client-utils package (78da195)

4.2.1 (2022-07-11)

  • Add exports field to the package.json (#415)
  • Add LICENSE files to the package contents (#414)

4.2.0 (2022-07-05)

Repository was transformed into the monorepo. Now there are two packages: @uploadcare/upload-client and @uploadcare/rest-client.

They have locked versioning. So @uploadcare/rest-client is started from 4.2.0, and @uploadcare/upload-client has no any visible changes (except for the internal ones).

At the current stage, there are no any high-level wrappers at @uploadcare/rest-client. Only low-level typed wrappers over API methods are available. It means, that there are no pagination and no conversion job status polling, just bare request wrappers.

4.1.0 (2022-06-29)

Bug Fixes

  • Fix crashes when null metadata passed to the options (cbf5472)

4.0.1 (2022-06-10)

4.0.0 (2022-06-10)

BREAKING CHANGES

  • Drop < v16 Node support due to native AbortController usage (#377)
  • Removed CommonJS bundles (#377)
  • Removed option defaultEffects (#376)
  • Removed property cdnUrlModifiers of UploadcareFile instance (#376)
  • Removed property originalUrl of UploadcareFile instance. Use cdnUrl instead (#376)
  • Exported method uploadBase renamed to uploadDirect (#376)

Bug Fixes

  • pass contentType down to the node form-data (465722c)
  • react-native: module entry points for react-native (6d8a955)

Features

  • UploadcareFile: add s3Bucket property (#376)
  • UploadcareFile: add s3Url property (#376)
  • UploadClient: set empty options by default for method wrappers inside client instance (#375)

3.1.1 (2022-04-11)

3.1.0 (2022-04-11)

Bug Fixes

  • accept option `multipartMinFileSize (679eb8f)
  • calculate store parameter in a consistent way (2e423d2)

Features

  • file metadata support (dc9cf2d)
  • return contentInfo from fileInfo to user (5b9b99a)

3.0.0 (2022-02-24)

Bug Fixes

  • remove exports field at package.json (#360) (1e37542)
  • fix!: split progress info to computable and unknown ones (#363) (7638284), closes #363

BREAKING CHANGES

  • value property of progress info can be undefined instead of NaN in case of uploading from URL. See isComputable flag to detect whether value is available.

2.2.0 (2021-12-22)

Features

2.1.0 (2021-12-07)

Features

  • export UploadcareFile and UploadcareGroup types (#353) (29d1547)

2.0.0 (2021-11-15)

Features

  • feat!: add cjs and esm support (#283) (081f27e), closes #283
  • feat!: replace CancelController with native AbortController (#282) (020e1ae), closes #282
  • add mimeType to UploadcareFile type (33b6c58)
  • export high-level upload methods (1354018)
  • handle server error codes (948c9d1)
  • add option userAgent to pass custom user agent string or function (d74fefb)

BREAKING CHANGES

  • remove default export because webpack can't handle it without bugs
  • replace cancel key with signal in all cancelable methods
  • property response of UploadClientError now contains the whole response object ({ error: {...}})

1.1.5 (2021-06-28)

Bug Fixes

  • pass missing props from uploadFile down to the upload methods (#339) (e16dc73)

1.1.4 (2021-06-11)

Bug Fixes

  • checkForUrlDuplicates & saveUrlForRecurrentUploads parameters passed into common uploadFile method (201ee07)

1.1.3 (2021-03-17)

Bug Fixes

  • react-native: prevent app crashes while multipart uploading (#308) (5d305e6)
  • react-native: support direct uploads through FormData (#307) (428b039)

1.1.2 (2020-04-20)

Bug Fixes

  • multipart: implement retry for part uploading (#253) (e2330bb)
  • multipart: add is ready pool for mulipart upload (#254) (fe7ca2a)
  • multipart: implement multipart progress for node (#252) (b60eb83)
  • multipart: use browser contentType if option is not passed (#251) (f5ab80a)
  • multipart: use browser filename if option is not passed (#250) (749e4a9)

1.1.1 (2020-03-16)

Bug Fixes

1.1.0 (2020-03-03)

Features

  • implement push strategy with sockets for uploadFromUrl (#222) (4cafe97)
  • add deferred disconnect for push strategy (#229) (a9901f7)
  • add strong typed event emitter (#217) (35b9eef)
  • add custom race function (#177) (219c02a)

Bug Fixes

  • make fileName optional and remove it from default settings (#233) (a28d181)
  • remove timeout from uploadFromUrl function (#226) (76db2e4)
  • use direct import for CancelController and rename callback to stopRace (#216) (ea4ef7a)

1.0.1 (2020-01-13)

Bug Fixes

  • deps: update dependency form-data to v3 (#130) (1ece271)

1.0.0 (2019-12-23)

Changed

  • All methods return a Promise now instead of ThenableInterface
  • SettingsInterface was renamed to Settings
  • fileFrom was renamed to uploadFile.
  • groupFrom was renamed to uploadFileGroup.
  • request low-level API method is not exported outside now.
  • Method setSettings of UploadClient was renamed to updateSettings.
  • Methods (base, fromUrl, fromUrlStatus, group, groupInfo, info, multipartStart, multipartUpload, multipartComplete, multipart, uploadFile, uploadGroup) were exported from index.ts to make the tree shaking better.
  • Methods (base, fromUrl, fromUrlStatus, group, groupInfo, info, multipartStart, multipartUpload, multipartComplete, multipart, uploadFile, uploadGroup) accept options instead of settings as a second argument.
  • UploadClient now contains all low-level API methods (base, fromUrl, fromUrlStatus, group, groupInfo, info, multipartStart, multipartUpload, multipartComplete, multipart, fileFrom, groupFrom).
  • UploadcareGroup files now contain UploadcareFile[], but not FileInfo[].
  • README.md was updated according to library API.
  • FileData became NodeFile and BrowserFile.

Removed

  • UploadAPI class.
  • Thenable, CancelableThenable, BaseThenable, Upload classes implementing respective interfaces.
  • onReady, onUploaded callbacks.
  • addUpdateSettingsListener and removeUpdateSettingsListener from UploadClientInterface.
  • from param of uploadFile and uploadFileGroup.
  • FileFromEnum and GroupFromEnum.

Added

  • CancelController to make API calls cancellable. See README for how to use this feature. (#77)

1.0.0-alpha.5

Added

  • Support of multipart and big files uploading: multipartStart, multipartUpload, and multipartComplete methods to UploadAPI.
  • Support of canceling uploads and handling them for all API methods (info, fromUrl, fromUrlStatus, group, groupInfo).
  • DefaultSettingsInterface with required properties.
  • pollingTimeoutMilliseconds to SettingsInterface. Now you can adjust the timeout for checking is file ready, and checking is file being uploaded from URL.
  • maxConcurrentRequests setting that allows you to specify the number of concurrent requests.

Changed

  • FileFrom enum was renamed to FileFromEnum.
  • GroupFrom enum was renamed to GroupFromEnum.
  • Settings was renamed to SettingsInterface.
  • FileInfo was renamed to FileInfoInterface.
  • GroupInfo was renamed to GroupInfoInfoInterface.
  • OriginalImageInfo was renamed to OriginalImageInfoInterface.
  • RequestOptions was renamed to RequestOptionsInterface.
  • ProgressStatus was renamed to ProgressStatusInterface.
  • Audio type was renamed to AudioInterface.
  • Video type was renamed to VideoInterface.
  • ErrorRequestInfo type was renamed to ErrorRequestInfoInterface.
  • ErrorResponseInfoInfo type was renamed to ErrorResponseInfoInterface.
  • ProgressState was renamed to ProgressStateEnum.
  • ProgressParams was renamed to ProgressParamsInterface.
  • base method of Upload API now returns BaseThenableInterface<BaseResponse> instead of DirectUploadInterface.
  • info, fromUrl, fromUrlStatus, group, groupInfo now returns CancelableThenableInterface.
  • Progress is now calculated from 0 to 1 instead of 0 to 100

Fixed

  • Example with directUpload.onProgress in README.md.
  • All tests are passing now.
  • Mock server tests are passing now.

Removed

  • DirectUploadInterface was removed in favor of BaseThenableInterface<BaseResponse>.
  • BaseProgress was removed in favor of native ProgressEvent.
  • InfoResponse was removed in favor of FileInfoInterface.
  • Old code in folder ./.back.

1.0.0-alpha.4

Added

  • Wrappers for group paths of Upload API (group, groupInfo).
  • The high-level function for group uploading, aka filesGroupFrom.
  • Uploading progress for Node.js in the base method.

Changed

  • UploadFromInterface was renamed to FileUploadInterface.
  • FileProgress was renamed to ProgressParams.
  • UploadcareFile was renamed to UploadcareFileInterface.

1.0.0-alpha.3

Added

  • Support fileFrom 'uploaded' file (uuid).
  • Support of waiting status from /from_url/status/ endpoint.
  • Export some main types from the index.ts file. So you can import them now directly from @uploadcare/upload-client.
  • Throttling for request.
  • retryThrottledMaxTimes param to set count of max retries after throttled request (1 by default).
  • Uuid type.
  • Mock server for local testing.

Fixed

  • The default timeout for polling functions increased from 3s to 10s.
  • Removed restrictions for timeout and interval.

1.0.0-alpha.2

Changed

  • The project was moved from Flow notations to TypeScript.
  • The base function now returns an object that implements DirectUploadInterface.
  • The fileFrom function now returns an object that implements UploadFromInterface.
  • The UCFile type renamed to UploadcareFile.
  • The progress of fileFrom now based on the UploadingProgress type.

Added

  • Low-level request wrappers for /from_url/ and /from_url/status/ paths of Upload API.
  • Settings: the support of setting baseCDN, checkForUrlDuplicates, saveUrlForRecurrentUploads.

1.0.0-alpha.1

Fixed

  • Use the version from the package.json file to create Uploadcare User Agent.

Changed

  • The base function returns thenable object called DirectUpload instead of using the promise property.
  • The fileFrom function returns thenable object called FilePromise instead of using the promise property.
  • The FileInfo type renamed to UCFile and updated.
  • The FilePromise resolved with an object of the UploadcareFile type.
  • The progress of fileFrom now based on the FilePromiseProgress type.
  • Updated the InfoResponse type.

Added

  • The checkFileIsReady function to check if the file is ready on the CDN.
  • New properties for the object that the fileFrom function returns: onUploaded, onReady.
  • The camelizeKeys function for inner usage.
  • The baseCDN default setting

1.0.0-alpha

The first public alpha release.

Added

  • The request function to request to any path of Upload API.
  • Low-level request wrappers for /base/ and /info/ paths of Upload API.
  • UploadClient class with settings and fileFrom method that supports only direct uploads now.
  • Support of following Uploadcare Settings: publicKey, baseUrl, doNotStore, integration, secureExpire, secureSignature.
  • Test environment for both Node.js and browsers