0.5.1 • Published 3 years ago

tiny-oss v0.5.1

Weekly downloads
36
License
MIT
Repository
github
Last release
3 years ago

tiny-oss

A tiny aliyun oss sdk for browser which focus on uploading. Less than 10kb (min+gzipped).

English | 简体中文

Installation

Npm

npm install tiny-oss

Yarn

yarn add tiny-oss

Usage

Basic

const oss = new TinyOSS({
  accessKeyId: 'your accessKeyId',
  accessKeySecret: 'your accessKeySecret',
  // Recommend to use the stsToken option in browser
  stsToken: 'security token',
  region: 'oss-cn-beijing',
  bucket: 'your bucket'
});

const blob = new Blob(['hello world'], { type: 'text/plain' });

// Upload
oss.put('hello-world', blob);

Upload progress

You can specify the third parameter to monitor the upload progress data:

// Upload progress
oss.put('hello-world', blob, {
  onprogress (e) {
    console.log('total: ', e.total, ', uploaded: ', e.loaded);
  }
});

More options or methods see API.

Compatibility

This package depends on some modern Web APIs, such as Blob, Uint8Array, FileReader, Promise.

So, it should work in the below browsers.

  • Chrome >= 20
  • Edge >= 12
  • IE >= 10
  • Firefox >= 4
  • Safari >= 8
  • Opera >= 11
  • Android >= 4.4.4
  • iOS >= 8

For IE and low version FireFox, you should import a promise polyfill, such as es6-promise.

API

new TinyOSS(options)

options

Please check Browser.js offical document.

  • accessKeyId
  • accessKeySecret
  • stsToken
  • bucket
  • endpoint
  • region
  • secure
  • timeout

put(objectName, blob, options)

Upload the blob.

Arguments

Return

  • (Promise)

putSymlink(objectName, targetObjectName)

Create a symlink.

Arguments

  • objectName (String): The symlink object name.
  • targetObjectName (String): The target object name.

Return

  • (Promise)

signatureUrl(objectName, options)

Get a signature url to download the file.

Arguments

Return

  • (String)

LICENSE

MIT

0.5.1

3 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.0

5 years ago