uploadcare-rest
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Uploadcare Rest

npm version

This is a wrapper around the API made available by uploadcare. The library is written in TypeScript and has typings available.

The methods will be implemented gradually.

Currently implemented

Files

  • copy
  • remove
  • store

Example

const uploader = new Uploadcare(
    config.uploadcare.publicKey,
    config.uploadcare.privateKey,
);

// Copy a file to the CDN storage, for example a crop preview
const response = await uploader.files.copy(cdnUrlOrId);
const image = response.data;

// Check the type of the image. url for custom storage, file otherwise.
if (image.type === 'file') {
    // Type cast for TypeScript only
    const result = <UploadImageResult>image.result;
}

Upload

Example

const uploader = new Uploadcare(
    config.uploadcare.publicKey,
    config.uploadcare.privateKey,
);

const file = await uploader.upload.awaitFromUrl('https://picsum.photos/200/300/?random');
// That's all, the library takes care of checking the upload progress
// If you're not interested in waiting for the file, use the following
const idc = await uploader.upload.fromUrl('https://picsum.photos/200/300/?random');

/uploadcare-rest/

    Package Sidebar

    Install

    npm i uploadcare-rest

    Weekly Downloads

    9

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    20.3 kB

    Total Files

    12

    Last publish

    Collaborators

    • -waylander-