ali-oss
aliyun oss(object storage service) node client
Last updated a month ago by peizerao .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ali-oss 
SYNC missed versions from official npm registry.

oss-js-sdk

NPM version build status coverage David deps

aliyun OSS(Object Storage Service) js client for Node and Browser env.

NOTE: For SDK 5.X document, please go to README.md

Install

npm install ali-oss --save

Compatibility

Node

Node.js >= 8.0.0 required. You can use 4.x in Node.js < 8.

Browser

  • IE >= 10 & Edge
  • Major versions of Chrome/Firefox/Safari
  • Major versions of Android/iOS/WP

Note:

  • For Lower browsers you can refer to PostObject, if you want to see more practices ,please refer to Web Post

QA

You can join DingDing Talk Group, Group Link

License

MIT

OSS Usage

OSS, Object Storage Service. Equal to well known Amazon S3.

All operation use es7 async/await to implement. All api is async function.

Summary

Node Usage

Compatibility

  • Node: >= 8.0.0

Basic usage

1.install SDK using npm

npm install ali-oss --save

2.for example:

const OSS = require('ali-oss');
const client = new OSS({
  region: '<oss region>',
  accessKeyId: '<Your accessKeyId>',
  accessKeySecret: '<Your accessKeySecret>',
  bucket: '<Your bucket name>'
});

Browser Usage

You can use most of the functionalities of ali-oss in browser with some exceptions:

  • put object with streaming: no chunked encoding, we use multipart upload instead
  • get object to local file: we cannot manipulate file system in browser, we provide signed object url for downloading needs
  • bucket operations(listBuckets, putBucketLogging, etc) will fail: OSS server currently do not support CORS requests for bucket operations (will probably be fixed later)

Compatibility

  • IE >= 10 & Edge
  • Major versions of Chrome/Firefox/Safari
  • Major versions of Android/iOS/WP

    Note: Because some browsers do not support promises, you need to introduce promise compatible libraries.
    For example: IE10 and IE11 need to introduce a promise-polyfill.

Setup

Bucket setup

As browser-side javascript involves CORS operations. You need to setup your bucket CORS rules to allow CORS operations:

  • set allowed origins to '*'
  • allowed methods to 'PUT, GET, POST, DELETE, HEAD'
  • set allowed headers to '*'
  • expose 'ETag' in expose headers

STS setup

As we don't want to expose the accessKeyId/accessKeySecret in the browser, a [common practice][oss-sts] is to use STS to grant temporary access.

Basic usage

Include the sdk lib in the <script> tag and you have OSS available for creating client.

 // x.x.x The specific version number represented
 // we recommend introducing offline resources, because the usability of online resources depends on the stability of the cdn server.
 <!-- Introducing online resources -->
 <script src="http://gosspublic.alicdn.com/aliyun-oss-sdk-x.x.x.min.js"></script>
 <!-- Introducing offline resources -->
 <script src="./aliyun-oss-sdk-x.x.x.min.js"></script>

<script type="text/javascript">
  const client = new OSS({
    region: 'oss-cn-hangzhou',
    accessKeyId: '<access-key-id>',
    accessKeySecret: '<access-key-secret>',
    bucket: '<bucket-name>',
    stsToken: '<security-token>'
  });

  client.list().then((result) => {
    console.log('objects: %j', result.objects);
    return client.put('my-obj', new OSS.Buffer('hello world'));
  }).then((result) => {
    console.log('put result: %j', result);
    return client.get('my-obj');
  }).then((result) => {
    console.log('get result: %j', result.content.toString());
  });
</script>

The full sample can be found [here][browser-sample].

How to build

npm run build-dist

And see the build artifacts under dist/.

Data Regions

OSS current data regions.

region country city endpoint internal endpoint
oss-cn-hangzhou China HangZhou oss-cn-hangzhou.aliyuncs.com oss-cn-hangzhou-internal.aliyuncs.com
oss-cn-shanghai China ShangHai oss-cn-shanghai.aliyuncs.com oss-cn-shanghai-internal.aliyuncs.com
oss-cn-qingdao China QingDao oss-cn-qingdao.aliyuncs.com oss-cn-qingdao-internal.aliyuncs.com
oss-cn-beijing China BeiJing oss-cn-beijing.aliyuncs.com oss-cn-beijing-internal.aliyuncs.com
oss-cn-shenzhen China ShenZhen oss-cn-shenzhen.aliyuncs.com oss-cn-shenzhen-internal.aliyuncs.com
oss-cn-hongkong China HongKong oss-cn-hongkong.aliyuncs.com oss-cn-hongkong-internal.aliyuncs.com
oss-us-west-1 US Silicon Valley oss-us-west-1.aliyuncs.com oss-us-west-1-internal.aliyuncs.com
oss-ap-southeast-1 Singapore Singapore oss-ap-southeast-1.aliyuncs.com oss-ap-southeast-1-internal.aliyuncs.com

Create Account

Go to OSS website, create a new account for new user.

After account created, you can create the OSS instance and get the accessKeyId and accessKeySecret.

Create A Bucket Instance

Each OSS instance required accessKeyId, accessKeySecret and bucket.

oss(options)

Create a Bucket store instance.

options:

  • accessKeyId {String} access key you create on aliyun console website
  • accessKeySecret {String} access secret you create
  • [stsToken] {String} used by temporary authorization, detail see
  • [bucket] {String} the default bucket you want to access If you don't have any bucket, please use putBucket() create one first.
  • [endpoint] {String} oss region domain. It takes priority over region.
  • [region] {String} the bucket data region location, please see Data Regions, default is oss-cn-hangzhou.
  • [internal] {Boolean} access OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set true to save lot of money.
  • [secure] {Boolean} instruct OSS client to use HTTPS (secure: true) or HTTP (secure: false) protocol.
  • [timeout] {String|Number} instance level timeout for all operations, default is 60s.
  • [cname] {Boolean}, default false, access oss with custom domain name. if true, you can fill endpoint field with your custom domain name,
  • [isRequestPay] {Boolean}, default false, whether request payer function of the bucket is open, if true, will send headers 'x-oss-request-payer': 'requester' to oss server. the details you can see requestPay
  • [useFetch] {Boolean}, default false, it just work in Browser, if true,it means upload object with fetch mode ,else XMLHttpRequest

example:

const oss = require('ali-oss');

const store = oss({
  accessKeyId: 'your access key',
  accessKeySecret: 'your access secret',
  bucket: 'your bucket name',
  region: 'oss-cn-hangzhou'
});

Bucket Operations

.listBuckets(query[, options])

List buckets in this account.

parameters:

  • [query] {Object} query parameters, default is null
    • [prefix] {String} search buckets using prefix key
    • [marker] {String} search start from marker, including marker key
    • [max-keys] {String|Number} max buckets, default is 100, limit to 1000
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return buckets list on buckets properties.

  • buckets {Array<BucketMeta>} bucket meta info list Each BucketMeta will contains blow properties:
    • name {String} bucket name
    • region {String} bucket store data region, e.g.: oss-cn-hangzhou-a
    • creationDate {String} bucket create GMT date, e.g.: 2015-02-19T08:39:44.000Z
  • owner {Object} object owner, including id and displayName
  • isTruncated {Boolean} truncate or not
  • nextMarker {String} next marker string
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • List top 10 buckets
store.listBuckets({
  "max-keys": 10
}).then((result) => {
  console.log(result);
});

.putBucket(name[, options])

Create a new bucket.

parameters:

  • name {String} bucket name If bucket exists and not belong to current account, will throw BucketAlreadyExistsError. If bucket not exists, will create a new bucket and set it's ACL.
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout
    • [StorageClass] {String} the storage type include (Standard,IA,Archive)

Success will return the bucket name on bucket properties.

  • bucket {String} bucket name
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Create a bucket name helloworld location on HongKong
store.putBucket('helloworld').then((result) => {
  // use it by default
  store.useBucket('helloworld');
});
  • Create a bucket name helloworld location on HongKong StorageClass Archive
await store.putBucket('helloworld', { StorageClass: 'Archive' });
// use it by default
store.useBucket('helloworld');

.deleteBucket(name[, options])

Delete an empty bucket.

parameters:

  • name {String} bucket name If bucket is not empty, will throw BucketNotEmptyError. If bucket is not exists, will throw NoSuchBucketError.
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Delete the exists 'helloworld' bucket on 'oss-cn-hongkong'
store.deleteBucket('helloworld').then((result) => {});

.useBucket(name)

Use the bucket.

parameters:

  • name {String} bucket name

example:

  • Use helloworld as the default bucket
store.useBucket('helloworld');

.getBucketInfo(name)

Get bucket information,include CreationDate、ExtranetEndpoint、IntranetEndpoint、Location、Name、StorageClass、 Owner、AccessControlList、Versioning

parameters:

  • name {String} bucket name

example:

  • Use helloworld as the default bucket
store.getBucketInfo('helloworld').then( (res) => {
  console.log(res.bucket)
})

.getBucketLocation(name)

Get bucket location

parameters:

  • name {String} bucket name

example:

  • Use helloworld as the default bucket
store.getBucketLocation('helloworld').then( (res) => {
  console.log(res.location)
})

.putBucketACL(name, acl[, options])

Update the bucket ACL.

parameters:

  • name {String} bucket name
  • acl {String} access control list, current available: public-read-write, public-read and private
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Set bucket helloworld to public-read-write
store.putBucketACL('helloworld', 'public-read-write').then((result) => {
});

.getBucketACL(name[, options])

Get the bucket ACL.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • acl {String} acl settiongs string
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Get bucket helloworld
store.getBucketACL('helloworld').then((result) => {
  console.log(result.acl);
});

.putBucketLogging(name, prefix[, options])

Update the bucket logging settings. Log file will create every one hour and name format: <prefix><bucket>-YYYY-mm-DD-HH-MM-SS-UniqueString.

parameters:

  • name {String} bucket name
  • [prefix] {String} prefix path name to store the log files
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Enable bucket helloworld logging and save with prefix logs/
store.putBucketLogging('helloworld', 'logs/').then((result) => {
});

.getBucketLogging(name[, options])

Get the bucket logging settings.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • enable {Boolean} enable logging or not
  • prefix {String} prefix path name to store the log files, maybe null
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Get bucket helloworld logging settings
store.getBucketLogging('helloworld').then((result) => {
  console.log(result.enable, result.prefix);
});

.deleteBucketLogging(name[, options])

Delete the bucket logging settings.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.putBucketWebsite(name, config[, options])

Set the bucket as a static website.

parameters:

  • name {String} bucket name
  • config {Object} website config, contains blow properties:
    • index {String} default page, e.g.: index.html
    • [error] {String} error page, e.g.: 'error.html'
    • [supportSubDir] {String} default vaule false
    • [type] {String} default value 0
    • [routingRules] {Array} RoutingRules
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

store.putBucketWebsite('hello', {
  index: 'index.html'
}).then((result) => {
});

.getBucketWebsite(name[, options])

Get the bucket website config.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • index {String} index page
  • error {String} error page, maybe null
  • supportSubDir {String}
  • type {String}
  • routingRules {Array}
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.deleteBucketWebsite(name[, options])

Delete the bucket website config.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.putBucketReferer(name, allowEmpty, referers[, options])

Set the bucket request Referer white list.

parameters:

  • name {String} bucket name
  • allowEmpty {Boolean} allow empty request referer or not
  • referers {Array<String>} Referer white list, e.g.:
    [
      'https://npm.taobao.org',
      'http://cnpmjs.org'
    ]
    
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

store.putBucketReferer('hello', false, [
  'https://npm.taobao.org',
  'http://cnpmjs.org'
]).then((result) => {
});

.getBucketReferer(name[, options])

Get the bucket request Referer white list.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • allowEmpty {Boolean} allow empty request referer or not
  • referers {Array<String>} Referer white list
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.deleteBucketReferer(name[, options])

Delete the bucket request Referer white list.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.putBucketLifecycle(name, rules[, options])

Set the bucket object lifecycle.

parameters:

  • name {String} bucket name
  • rules {Array<Rule>} rule config list, each Rule will contains blow properties:
    • [id] {String} rule id, if not set, OSS will auto create it with random string.
    • prefix {String} store prefix
    • status {String} rule status, allow values: Enabled or Disabled
    • [expiration] {Object} specifies the expiration attribute of the lifecycle rules for the object.
      • [days] {Number|String} expire after the days
      • [createdBeforeDate] {String} expire date, e.g.: 2022-10-11T00:00:00.000Z
      • [expiredObjectDeleteMarker] {String} value true createdBeforeDate and days and expiredObjectDeleteMarker must have one.
    • [abortMultipartUpload] {Object} Specifies the expiration attribute of the multipart upload tasks that are not complete.
      • [days] {Number|String} expire after the days
      • [createdBeforeDate] {String} expire date, e.g.: 2022-10-11T00:00:00.000Z createdBeforeDate and days must have one.
    • [transition] {Object} Specifies the time when an object is converted to the IA or archive storage class during a valid life cycle.
      • storageClass {String} Specifies the storage class that objects that conform to the rule are converted into. allow values: IA or Archive
      • [days] {Number|String} expire after the days
      • [createdBeforeDate] {String} expire date, e.g.: 2022-10-11T00:00:00.000Z createdBeforeDate and days must have one.
    • [noncurrentVersionTransition] {Object} Specifies the time when an object is converted to the IA or archive storage class during a valid life cycle.
      • storageClass {String} Specifies the storage class that history objects that conform to the rule are converted into. allow values: IA or Archive
      • noncurrentDays {String} expire after the noncurrentDays expirationabortMultipartUploadtransitionnoncurrentVersionTransition must have one.
    • [noncurrentVersionExpiration] {Object} specifies the expiration attribute of the lifecycle rules for the history object.
      • noncurrentDays {String} expire after the noncurrentDays
    • [tag] {Object} Specifies the object tag applicable to a rule. Multiple tags are supported.
      • key {String} Indicates the tag key.
      • value {String} Indicates the tag value. tag cannot be used with abortMultipartUpload
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

store.putBucketLifecycle('hello', [
  {
    id: 'delete after one day',
    prefix: 'logs/',
    status: 'Enabled',
    days: 1
  },
  {
    prefix: 'logs2/',
    status: 'Disabled',
    date: '2022-10-11T00:00:00.000Z'
  }
]).then((result) => {});

example: for history with noncurrentVersionExpiration

 const result = await store.putBucketLifecycle(bucket, [{
  id: 'expiration1',
  prefix: 'logs/',
  status: 'Enabled',
  expiration: {
    days: '1'
  },
  noncurrentVersionExpiration: {
    noncurrentDays: '1'
  }
}]);
console.log(result)

example: for history with expiredObjectDeleteMarker

 const result = await store.putBucketLifecycle(bucket, [{
  id: 'expiration1',
  prefix: 'logs/',
  status: 'Enabled',
  expiration: {
    expiredObjectDeleteMarker: 'true'
  },
  noncurrentVersionExpiration: {
    noncurrentDays: '1'
  }
}]);
console.log(result)

example: for history with noncurrentVersionTransition

 const result = await store.putBucketLifecycle(bucket, [{
  id: 'expiration1',
  prefix: 'logs/',
  status: 'Enabled',
  noncurrentVersionTransition: {
    noncurrentDays: '10',
    storageClass: 'IA'
  }
}]);
console.log(result)

.getBucketLifecycle(name[, options])

Get the bucket object lifecycle.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • rules {Array<Rule>} the lifecycle rule list
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.deleteBucketLifecycle(name[, options])

Delete the bucket object lifecycle.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.putBucketCORS(name, rules[, options])

Set CORS rules of the bucket object

parameters:

  • name {String} bucket name
  • rules {Array<Rule>} rule config list, each Rule will contains below properties:
    • allowedOrigin {String/Array} configure for Access-Control-Allow-Origin header
    • allowedMethod {String/Array} configure for Access-Control-Allow-Methods header
    • [allowedHeader] {String/Array} configure for Access-Control-Allow-Headers header
    • [exposeHeader] {String/Array} configure for Access-Control-Expose-Headers header
    • [maxAgeSeconds] {String} configure for Access-Control-Max-Age header
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

store.putBucketCORS('hello', [
  {
    allowedOrigin: '*',
    allowedMethod: [
      'GET',
      'HEAD',
    ],
  }
]).then((result) => {});

.getBucketCORS(name[, options])

Get CORS rules of the bucket object.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • rules {Array<Rule>} the CORS rule list
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.deleteBucketCORS(name[, options])

Delete CORS rules of the bucket object.

parameters:

  • name {String} bucket name
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

.getBucketRequestPayment(bucketName[, options])

get RequestPayment value of the bucket object.

parameters:

  • bucketName {String} bucket name
  • [options] {Object} optional parameters

Success will return:

  • status {Number} response status
  • payer {String} payer, BucketOwner or Requester
  • res {Object} response info, including
    • data {Buffer} xml

.putBucketRequestPayment(bucketName, payer[, options])

put RequestPayment value of the bucket object.

parameters:

  • bucketName {String}
  • payer {String} payer
  • [options] {Object} optional parameters

Success will return:

  • status {Number} response status
  • res {Object} response info

.putBucketEncryption(name, rules)

put BucketEncryption value of the bucket object.

parameters:

  • name {String} bucket name
  • [rules] {Object} parameters
    • SSEAlgorithm {String} encryption type, expect AES256 or KMS
    • {KMSMasterKeyID} {String} needed when encryption type is KMS

Success will return:

  • status {Number} response status
  • res {Object} response info

.getBucketEncryption(name)

get BucketEncryption rule value of the bucket object.

parameters:

  • name {String} bucket name

Success will return:

  • status {Number} response status
  • res {Object} response info
  • encryption {Object} rules
    • SSEAlgorithm {String} encryption type, AES256 or KMS
    • {KMSMasterKeyID} {String} will be return when encryption type is KMS

.deleteBucketEncryption(name)

delete BucketEncryption rule value of the bucket object.

parameters:

  • name {String} bucket name

Success will return:

  • status {Number} response status
  • res {Object} response info

.putBucketTags(name, tag[, options])

Adds tags for a bucket or modify the tags for a bucket.

parameters:

  • name {String} the object name
  • tag {Object} tag, eg. {var1: value1,var2:value2}
  • [options] {Object} optional args

Success will return:

  • status {Number} response status
  • res {Object} response info

.getBucketTags(name[, options])

Obtains the tags for a bucket.

parameters:

  • name {String} the object name
  • [options] {Object} optional args

Success will return:

  • tag {Object} the tag of object
  • res {Object} response info

.deleteBucketTags(name[, options])

Deletes the tags added for a bucket.

parameters:

  • name {String} the object name
  • [options] {Object} optional args

Success will return:

  • status {Number} response status
  • res {Object} response info

.putBucketPolicy(name, policy[, options])

Adds or modify policy for a bucket.

parameters:

  • name {String} the bucket name
  • policy {Object} bucket policy
  • [options] {Object} optional args

Success will return:

  • status {Number} response status
  • res {Object} response info

example:

const policy = {
  Version: '1',
  Statement: [
    {
      Action: ['oss:PutObject', 'oss:GetObject'],
      Effect: 'Deny',
      Principal: ['1234567890'],
      Resource: ['acs:oss:*:1234567890:*/*']
    }
  ]
};
const result = await store.putBucketPolicy(bucket, policy);
console.log(result);

.getBucketPolicy(name[, options])

Obtains the policy for a bucket.

parameters:

  • name {String} the bucket name
  • [options] {Object} optional args

Success will return:

  • policy {Object} the policy of bucket, if not exist, the value is null
  • res {Object} response info
  • status {Number} response status

.deleteBucketPolicy(name[, options])

Deletes the policy added for a bucket.

parameters:

  • name {String} the bucket name
  • [options] {Object} optional args

Success will return:

  • status {Number} response status
  • res {Object} response info

.getBucketVersioning(name[, options])

Obtains the version status of an object

parameters:

  • name {String} the bucket name
  • [options] {Object} optional args

Success will return:

  • status {Number} response status
  • versionStatus {String | undefined} version status, Suspended or Enabled. default value: undefined
  • res {Object} response info

.putBucketVersioning(name, status[, options])

set the version status of an object

parameters:

  • name {String} the bucket name
  • status {String} version status, allow values: Enabled or Suspended
  • [options] {Object} optional args

Success will return:

  • status {Number} response status
  • res {Object} response info

Object Operations

All operations function return Promise, except signatureUrl.

.put(name, file[, options])

Add an object to the bucket.

parameters:

  • name {String} object name store on OSS
  • file {String|Buffer|ReadStream|File(only support Browser)|Blob(only support Browser)} object local path, content buffer or ReadStream content instance use in Node, Blob and html5 File
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout
    • [mime] {String} custom mime, will send with Content-Type entity header
    • [meta] {Object} user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 }
    • [callback] {Object} The callback parameter is composed of a JSON string encoded in Base64,detail see
      • url {String} After a file is uploaded successfully, the OSS sends a callback request to this URL.
      • [host] {String} The host header value for initiating callback requests.
      • body {String} The value of the request body when a callback is initiated, for example, key=$(key)&etag=$(etag)&my_var=$(x:my_var).
      • [contentType] {String} The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value.
      • [customValue] {Object} Custom parameters are a map of key-values
        e.g.:
           var customValue = {var1: 'value1', var2: 'value2'}
        
    • [headers] {Object} extra headers
      • 'Cache-Control' cache control for download, e.g.: Cache-Control: public, no-cache
      • 'Content-Disposition' object name for download, e.g.: Content-Disposition: somename
      • 'Content-Encoding' object content encoding for download, e.g.: Content-Encoding: gzip
      • 'Expires' expires time (milliseconds) for download, e.g.: Expires: 3600000
      • See more: PutObject

Success will return the object information.

object:

  • name {String} object name
  • data {Object} callback server response data, sdk use JSON.parse() return
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Add an object through local file path
const filepath = '/home/ossdemo/demo.txt';
store.put('ossdemo/demo.txt', filepath).then((result) => {
  console.log(result);
});

{
  name: 'ossdemo/demo.txt',
  res: {
    status: 200,
    headers: {
      date: 'Tue, 17 Feb 2015 13:28:17 GMT',
      'content-length': '0',
      connection: 'close',
      etag: '"BF7A03DA01440845BC5D487B369BC168"',
      server: 'AliyunOSS',
      'x-oss-request-id': '54E341F1707AA0275E829244'
    },
    size: 0,
    rt: 92
  }
}
  • Add an object through content buffer
store.put('ossdemo/buffer', Buffer.from('foo content')).then((result) => {
  console.log(result);
});

{
  name: 'ossdemo/buffer',
  url: 'http://demo.oss-cn-hangzhou.aliyuncs.com/ossdemo/buffer',
  res: {
    status: 200,
    headers: {
      date: 'Tue, 17 Feb 2015 13:28:17 GMT',
      'content-length': '0',
      connection: 'close',
      etag: '"xxx"',
      server: 'AliyunOSS',
      'x-oss-request-id': '54E341F1707AA0275E829243'
    },
    size: 0,
    rt: 92
  }
}
  • Add an object through readstream
const filepath = '/home/ossdemo/demo.txt';
store.put('ossdemo/readstream.txt', fs.createReadStream(filepath)).then((result) => {
  console.log(result);
});

{
  name: 'ossdemo/readstream.txt',
  url: 'http://demo.oss-cn-hangzhou.aliyuncs.com/ossdemo/readstream.txt',
  res: {
    status: 200,
    headers: {
      date: 'Tue, 17 Feb 2015 13:28:17 GMT',
      'content-length': '0',
      connection: 'close',
      etag: '"BF7A03DA01440845BC5D487B369BC168"',
      server: 'AliyunOSS',
      'x-oss-request-id': '54E341F1707AA0275E829242'
    },
    size: 0,
    rt: 92
  }
}

.putStream(name, stream[, options])

Add a stream object to the bucket.

parameters:

  • name {String} object name store on OSS
  • stream {ReadStream} object ReadStream content instance
  • [options] {Object} optional parameters
    • [contentLength] {Number} the stream length, chunked encoding will be used if absent
    • [timeout] {Number} the operation timeout
    • [mime] {String} custom mime, will send with Content-Type entity header
    • [meta] {Object} user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 }
    • [callback] {Object} The callback parameter is composed of a JSON string encoded in Base64,detail see
      • url {String} After a file is uploaded successfully, the OSS sends a callback request to this URL.
      • [host] {String} The host header value for initiating callback requests.
      • body {String} The value of the request body when a callback is initiated, for example, key=$(key)&etag=$(etag)&my_var=$(x:my_var).
      • [contentType] {String} The Content-Type of the callback requests initiatiated, It supports application/x-www-form-urlencoded and application/json, and the former is the default value.
      • [customValue] {Object} Custom parameters are a map of key-values
        e.g.:
           var customValue = {var1: 'value1', var2: 'value2'}
        
    • [headers] {Object} extra headers, detail see RFC 2616
      • 'Cache-Control' cache control for download, e.g.: Cache-Control: public, no-cache
      • 'Content-Disposition' object name for download, e.g.: Content-Disposition: somename
      • 'Content-Encoding' object content encoding for download, e.g.: Content-Encoding: gzip
      • 'Expires' expires time (milliseconds) for download, e.g.: Expires: 3600000

Success will return the object information.

object:

  • name {String} object name
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Add an object through readstream
const filepath = '/home/ossdemo/demo.txt';
store.putStream('ossdemo/readstream.txt', fs.createReadStream(filepath)).then((result) => {
  console.log(result);
});

{
  name: 'ossdemo/readstream.txt',
  url: 'http://demo.oss-cn-hangzhou.aliyuncs.com/ossdemo/readstream.txt',
  res: {
    status: 200,
    headers: {
      date: 'Tue, 17 Feb 2015 13:28:17 GMT',
      'content-length': '0',
      connection: 'close',
      etag: '"BF7A03DA01440845BC5D487B369BC168"',
      server: 'AliyunOSS',
      'x-oss-request-id': '54E341F1707AA0275E829242'
    },
    size: 0,
    rt: 92
  }
}

.append(name, file[, options])

Append an object to the bucket, it's almost same as put, but it can add content to existing object rather than override it.

All parameters are same as put except for options.position

  • name {String} object name store on OSS
  • file {String|Buffer|ReadStream} object local path, content buffer or ReadStream content instance
  • [options] {Object} optional parameters
    • [position] {String} specify the position which is the content length of the latest object
    • [timeout] {Number} the operation timeout
    • [mime] {String} custom mime, will send with Content-Type entity header
    • [meta] {Object} user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 }
    • [headers] {Object} extra headers, detail see RFC 2616
      • 'Cache-Control' cache control for download, e.g.: Cache-Control: public, no-cache
      • 'Content-Disposition' object name for download, e.g.: Content-Disposition: somename
      • 'Content-Encoding' object content encoding for download, e.g.: Content-Encoding: gzip
      • 'Expires' expires time (milliseconds) for download, e.g.: Expires: 3600000

object:

  • name {String} object name
  • url {String} the url of oss
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)
  • nextAppendPosition {String} the next position

example:

let object = await store.append('ossdemo/buffer', Buffer.from('foo'));

// append content to the existing object
object = await store.append('ossdemo/buffer', Buffer.from('bar'), {
  position: object.nextAppendPosition,
});

.getObjectUrl(name[, baseUrl])

Get the Object url. If provide baseUrl, will use baseUrl instead the default endpoint.

e.g.:

const cdnUrl = client.getObjectUrl('foo/bar.jpg', 'https://mycdn.domian.com');
// cdnUrl should be `https://mycdn.domian.com/foo/bar.jpg`

.generateObjectUrl(name[, baseUrl])

Get the Object url. If provide baseUrl, will use baseUrl instead the default bucket and endpoint. Suggest use generateObjectUrl instead of getObjectUrl.

e.g.:

const url = client.generateObjectUrl('foo/bar.jpg');
// cdnUrl should be `https://${bucketname}.${endpotint}foo/bar.jpg`

const cdnUrl = client.generateObjectUrl('foo/bar.jpg', 'https://mycdn.domian.com');
// cdnUrl should be `https://mycdn.domian.com/foo/bar.jpg`

.head(name[, options])

Head an object and get the meta info.

parameters:

  • name {String} object name store on OSS
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout
    • [versionId] {String} the version id of history object
    • [headers] {Object} extra headers, detail see RFC 2616
      • 'If-Modified-Since' object modified after this time will return 200 and object meta, otherwise return 304 not modified
      • 'If-Unmodified-Since' object modified before this time will return 200 and object meta, otherwise throw PreconditionFailedError
      • 'If-Match' object etag equal this will return 200 and object meta, otherwise throw PreconditionFailedError
      • 'If-None-Match' object etag not equal this will return 200 and object meta, otherwise return 304 not modified

Success will return the object's meta information.

object:

  • status {Number} response status, maybe 200 or 304
  • meta {Object} object user meta, if not set on put(), will return null. If return status 304, meta will be null too
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
      • [x-oss-version-id] return in multiversion
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Head an exists object and get user meta
await this.store.put('ossdemo/head-meta', Buffer.from('foo'), {
  meta: {
    uid: 1,
    path: 'foo/demo.txt'
  }
});
const object = await this.store.head('ossdemo/head-meta');
console.log(object);

{
  status: 200,
  meta: {
    uid: '1',
    path: 'foo/demo.txt'
  },
  res: { ... }
}
  • Head a not exists object
const object = await this.store.head('ossdemo/head-meta');
// will throw NoSuchKeyError

.getObjectMeta(name[, options])

Get an object meta info include ETag、Size、LastModified and so on, not return object content.

parameters:

  • name {String} object name store on OSS
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout
    • [versionId] {String} the version id of history object

Success will return the object's meta information.

object:

  • status {Number} response status
  • res {Object} response info, including
    • headers {Object} response headers

example:

  • Head an exists object and get object meta info
await this.store.put('ossdemo/object-meta', Buffer.from('foo'));
const object = await this.store.getObjectMeta('ossdemo/object-meta');
console.log(object);

{
  status: 200,
  res: { ... }
}

.get(name[, file, options])

Get an object from the bucket.

parameters:

  • name {String} object name store on OSS
  • [file] {String|WriteStream} file path or WriteStream instance to store the content If file is null or ignore this parameter, function will return info contains content property.
  • [options] {Object} optional parameters
    • [versionId] {String} the version id of history object
    • [timeout] {Number} the operation timeout
    • [process] {String} image process params, will send with x-oss-process e.g.: {process: 'image/resize,w_200'}
    • [headers] {Object} extra headers, detail see RFC 2616
      • 'Range' get specifying range bytes content, e.g.: Range: bytes=0-9
      • 'If-Modified-Since' object modified after this time will return 200 and object meta, otherwise return 304 not modified
      • 'If-Unmodified-Since' object modified before this time will return 200 and object meta, otherwise throw PreconditionFailedError
      • 'If-Match' object etag equal this will return 200 and object meta, otherwise throw PreconditionFailedError
      • 'If-None-Match' object etag not equal this will return 200 and object meta, otherwise return 304 not modified

Success will return the info contains response.

object:

  • [content] {Buffer} file content buffer if file parameter is null or ignore
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

If object not exists, will throw NoSuchKeyError.

example:

  • Get an exists object and store it to the local file
const filepath = '/home/ossdemo/demo.txt';
await store.get('ossdemo/demo.txt', filepath);

_ Store object to a writestream

await store.get('ossdemo/demo.txt', somestream);
  • Get an object content buffer
const result = await store.get('ossdemo/demo.txt');
console.log(Buffer.isBuffer(result.content));
  • Get a processed image and store it to the local file
const filepath = '/home/ossdemo/demo.png';
await store.get('ossdemo/demo.png', filepath, {process: 'image/resize,w_200'});
  • Get a not exists object
const filepath = '/home/ossdemo/demo.txt';
await store.get('ossdemo/not-exists-demo.txt', filepath);
// will throw NoSuchKeyError
  • Get a historic version object
const filepath = '/home/ossdemo/demo.txt';
const versionId = 'versionId string';
await store.get('ossdemo/not-exists-demo.txt', filepath, {
  versionId
});

.getStream(name[, options])

Get an object read stream.

parameters:

  • name {String} object name store on OSS
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout
    • [process] {String} image process params, will send with x-oss-process
    • [headers] {Object} extra headers
      • 'If-Modified-Since' object modified after this time will return 200 and object meta, otherwise return 304 not modified
      • 'If-Unmodified-Since' object modified before this time will return 200 and object meta, otherwise throw PreconditionFailedError
      • 'If-Match' object etag equal this will return 200 and object meta, otherwise throw PreconditionFailedError
      • 'If-None-Match' object etag not equal this will return 200 and object meta, otherwise return 304 not modified

Success will return the stream instance and response info.

object:

  • stream {ReadStream} readable stream instance if response status is not 200, stream will be null.
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

If object not exists, will throw NoSuchKeyError.

example:

  • Get an exists object stream
const result = await store.getStream('ossdemo/demo.txt');
result.stream.pipe(fs.createWriteStream('some file.txt'));

.delete(name[, options])

Delete an object from the bucket.

parameters:

  • name {String} object name store on OSS
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout
    • [versionId] {String} the version id of history object

Success will return the info contains response.

object:

  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

If delete object not exists, will also delete success.

example:

  • Delete an exists object
await store.delete('ossdemo/someobject');
  • Delete a not exists object
await store.delete('ossdemo/some-not-exists-object');
  • Delete a history object or deleteMarker
const versionId = 'versionId';
await store.delete('ossdemo/some-not-exists-object', { versionId });

.copy(name, sourceName[, sourceBucket, options])

Copy an object from sourceName to name.

parameters:

  • name {String} object name store on OSS
  • sourceName {String} source object name
  • [sourceBucket] {String} source Bucket. if doesn't exist,sourceBucket is same bucket.
  • [options] {Object} optional parameters
    • [versionId] {String} the version id of history object
    • [timeout] {Number} the operation timeout
    • [meta] {Object} user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 } If the meta set, will override the source object meta.
    • [headers] {Object} extra headers
      • 'If-Match' do copy if source object etag equal this, otherwise throw PreconditionFailedError
      • 'If-None-Match' do copy if source object etag not equal this, otherwise throw PreconditionFailedError
      • 'If-Modified-Since' do copy if source object modified after this time, otherwise throw PreconditionFailedError
      • 'If-Unmodified-Since' do copy if source object modified before this time, otherwise throw PreconditionFailedError
      • See more: CopyObject

Success will return the copy result in data property.

object:

  • data {Object} copy result
    • lastModified {String} object last modified GMT string
    • etag {String} object etag contains ", e.g.: "5B3C1A2E053D763E1B002CC607C5A0FE"
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

If source object not exists, will throw NoSuchKeyError.

example:

  • Copy same bucket object
store.copy('newName', 'oldName').then((result) => {
  console.log(result);
});
  • Copy other bucket object
store.copy('logo.png', 'logo.png', 'other-bucket').then((result) => {
  console.log(result);
});
  • Copy historic object
const versionId = 'your verisonId'
store.copy('logo.png', 'logo.png', 'other-bucket', { versionId }).then((result) => {
  console.log(result);
});

.putMeta(name, meta[, options])

Set an exists object meta.

parameters:

  • name {String} object name store on OSS
  • meta {Object} user meta, will send with x-oss-meta- prefix string e.g.: { uid: 123, pid: 110 } If meta: null, will clean up the exists meta
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return the putMeta result in data property.

  • data {Object} copy result
    • lastModified {String} object last modified GMT date, e.g.: 2015-02-19T08:39:44.000Z
    • etag {String} object etag contains ", e.g.: "5B3C1A2E053D763E1B002CC607C5A0FE"
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

If object not exists, will throw NoSuchKeyError.

example:

  • Update exists object meta
const result = await store.putMeta('ossdemo.txt', {
  uid: 1, pid: 'p123'
});
console.log(result);
  • Clean up object meta
await store.putMeta('ossdemo.txt', null);

.deleteMulti(names[, options])

Delete multi objects in one request.

parameters:

  • names {Array<Object>} object names, max 1000 objects in once.
    • key {String} object name
    • [versionId] {String} the version id of history object or deleteMarker
  • [options] {Object} optional parameters
    • [quiet] {Boolean} quiet mode or verbose mode, default is false, verbose mode quiet mode: if all objects delete succes, return emtpy response. otherwise return delete error object results. verbose mode: return all object delete results.
    • [timeout] {Number} the operation timeout

Success will return delete success objects in deleted property.

  • [deleted] {Array<Object>} deleted object or deleteMarker info list
    • [Key] {String} object name
    • [VersionId] {String} object versionId
    • [DeleteMarker] {String} generate or delete marker
    • [DeleteMarkerVersionId] {String} marker versionId
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • Delete multi objects in quiet mode
const result = await store.deleteMulti(['obj1', 'obj2', 'obj3'], {
  quiet: true
});
  • Delete multi objects in verbose mode
const result = await store.deleteMulti(['obj1', 'obj2', 'obj3']);
  • Delete multi objects in multiversion
const obj1 = {
  key: 'key1',
  versionId: 'versionId1'
}
const obj2 = {
  key: 'key2',
  versionId: 'versionId2'
}
const result = await store.deleteMulti([obj1, obj2]);

.list(query[, options])

List objects in the bucket.

parameters:

  • [query] {Object} query parameters, default is null
    • [prefix] {String} search object using prefix key
    • [marker] {String} search start from marker, including marker key
    • [delimiter] {String} delimiter search scope e.g. / only search current dir, not including subdir
    • [max-keys] {String|Number} max objects, default is 100, limit to 1000
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return objects list on objects properties.

  • objects {Array<ObjectMeta>} object meta info list Each ObjectMeta will contains blow properties:
    • name {String} object name on oss
    • lastModified {String} object last modified GMT date, e.g.: 2015-02-19T08:39:44.000Z
    • etag {String} object etag contains ", e.g.: "5B3C1A2E053D763E1B002CC607C5A0FE"
    • type {String} object type, e.g.: Normal
    • size {Number} object size, e.g.: 344606
    • storageClass {String} storage class type, e.g.: Standard
    • owner {Object} object owner, including id and displayName
  • prefixes {Array<String>} prefix list
  • isTruncated {Boolean} truncate or not
  • nextMarker {String} next marker string
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • List top 10 objects
const result = await store.list();
console.log(result.objects);
  • List fun/ dir including subdirs objects
const result = await store.list({
  prefix: 'fun/'
});
console.log(result.objects);
  • List fun/ dir objects, not including subdirs
const result = await store.list({
  prefix: 'fun/',
  delimiter: '/'
});
console.log(result.objects);

.getBucketVersions(query[, options])

List objects in the bucket.

parameters:

  • [query] {Object} query parameters, default is null
    • [prefix] {String} search object using prefix key
    • [versionIdMarker] {String} set the result to return from the version ID marker of the key marker object and sort by the versions
    • [keyMarker] {String} search start from keyMarker, including keyMarker key
    • [encodingType] {String} specifies that the returned content is encoded, and specifies the type of encoding
    • [delimiter] {String} delimiter search scope e.g. / only search current dir, not including subdir
    • [maxKeys] {String|Number} max objects, default is 100, limit to 1000
  • [options] {Object} optional parameters
    • [timeout] {Number} the operation timeout

Success will return objects list on objects properties.

  • objects {Array<ObjectMeta>} object meta info list Each ObjectMeta will contains blow properties:
    • name {String} object name on oss
    • lastModified {String} object last modified GMT date, e.g.: 2015-02-19T08:39:44.000Z
    • etag {String} object etag contains ", e.g.: "5B3C1A2E053D763E1B002CC607C5A0FE"
    • type {String} object type, e.g.: Normal
    • size {Number} object size, e.g.: 344606
    • isLatest {Boolean}
    • versionId {String} object versionId
    • storageClass {String} storage class type, e.g.: Standard
    • owner {Object} object owner, including id and displayName
  • deleteMarker {Array<ObjectDeleteMarker>} object delete marker info list Each ObjectDeleteMarker
    • name {String} object name on oss
    • lastModified {String} object last modified GMT date, e.g.: 2015-02-19T08:39:44.000Z
    • versionId {String} object versionId
  • isTruncated {Boolean} truncate or not
  • nextMarker {String} next marker string
  • NextVersionIdMarker {String} next version ID marker string
  • res {Object} response info, including
    • status {Number} response status
    • headers {Object} response headers
    • size {Number} response size
    • rt {Number} request total use time (ms)

example:

  • View all versions of objects and deleteMarker of bucket
const result = await store.getBucketVersions();
console.log(result.objects);
console.log(result.deleteMarker);
  • List from key-marker
const result = await store.getBucketVersions({
  'keyMarker': 'keyMarker'
});
console.log(result.objects);
  • List from the version-id-marker of key-marker
const result = await store.getBucketVersions({
  'versionIdMarker': 'versionIdMarker',
  'keyMarker': 'keyMarker'
});
console.log(result.objects);
console.log(result.deleteMarker);

.signatureUrl(name[, options])

Create a signature url for download or upload object. When you put object with signatureUrl ,you need to pass Content-Type.Please look at the example.

parameters:

  • name {String} object name store on OSS
  • [options] {Object} optional parameters
    • [expires] {Number} after expires seconds, the url will become invalid, default is 1800
    • [method] {String} the HTTP method, default is 'GET'
    • [Content-Type] {String} set the request content type
    • [process] {String} image process params, will send with x-oss-process e.g.: {process: 'image/resize,w_200'}
    • [trafficLimit] {Number} traffic limit, range: 819200~838860800.
    • [subResource] {Object} additional signature parameters in url.
    • [response] {Object} set the response headers for download
    • [callback] {Object} set the callback for the operation
      • url {String} set the url for callback
      • [host] {String} set the host for callback
      • body {String} set the body for callback
      • [contentType] {String} set the type for body
      • [customValue] {Object} set the custom value for callback,eg. {var1: value1,var2:value2}

Success will return signature url.

example:

  • Get signature url for object
const url = store.signatureUrl('ossdemo.txt');
console.log(url);
// --------------------------------------------------
const url = store.signatureUrl('ossdemo.txt', {
  expires: 3600,
  method: 'PUT'
});
console.log(url);

//  put object with signatureUrl
// -------------------------------------------------

const url = store.signatureUrl('ossdemo.txt', {
  expires: 3600,
  method: 'PUT',
  'Content-Type': 'text/plain; charset=UTF-8',
});
console.log(url);

// --------------------------------------------------
const url = store.signatureUrl('ossdemo.txt', {
  expires: 3600,
  response: {
    'content-type': 'text/custom',
    'content-disposition': 'attachment'
  }
});
console.log(url);

// put operation
  • Get a signature url for a processed image
const url = store.signatureUrl('ossdemo.png', {
  process: 'image/resize,w_200'
});
console.log(url);
// --------------------------------------------------
const url = store.signatureUrl('ossdemo.png', {
  expires: 3600,
  process: 'image/resize,

Current Tags

  • 6.8.0-beta                                ...           beta (3 months ago)
  • 6.10.0                                ...           latest (a month ago)
  • 4.16.0                                ...           latest-4 (a year ago)
  • 5.3.2                                ...           latest-5 (2 years ago)

100 Versions

  • 6.10.0                                ...           a month ago
  • 6.9.1                                ...           2 months ago
  • 6.9.0                                ...           2 months ago
  • 6.8.0                                ...           3 months ago
  • 6.8.0-beta                                ...           3 months ago
  • 6.7.0                                ...           4 months ago
  • 6.6.0                                ...           4 months ago
  • 6.5.1                                ...           7 months ago
  • 6.5.0                                ...           7 months ago
  • 6.4.0-beta-1                                ...           7 months ago
  • 6.4.0-beta                                ...           7 months ago
  • 6.4.0                                ...           7 months ago
  • 6.3.1                                ...           8 months ago
  • 6.3.0                                ...           8 months ago
  • 6.2.1                                ...           9 months ago
  • 6.2.0                                ...           9 months ago
  • 4.16.0                                ...           a year ago
  • 6.1.1                                ...           a year ago
  • 6.1.1-beta.1                                ...           a year ago
  • 6.1.0                                ...           2 years ago
  • 6.0.2                                ...           2 years ago
  • 4.15.1                                ...           2 years ago
  • 6.0.1                                ...           2 years ago
  • 5.3.2                                ...           2 years ago
  • 6.0.0                                ...           2 years ago
  • 5.3.1                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.1                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 4.15.0                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 4.14.2                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.13.2                                ...           2 years ago
  • 4.13.1                                ...           2 years ago
  • 4.13.0                                ...           2 years ago
  • 4.12.2                                ...           3 years ago
  • 4.12.1                                ...           3 years ago
  • 4.11.4                                ...           3 years ago
  • 4.11.3                                ...           3 years ago
  • 4.11.2                                ...           3 years ago
  • 4.11.1                                ...           3 years ago
  • 4.11.0                                ...           3 years ago
  • 4.10.2                                ...           3 years ago
  • 4.10.1                                ...           3 years ago
  • 4.10.0                                ...           3 years ago
  • 4.9.0                                ...           3 years ago
  • 4.8.0                                ...           4 years ago
  • 4.7.3                                ...           4 years ago
  • 4.7.1                                ...           4 years ago
  • 4.7.0                                ...           4 years ago
  • 4.6.3                                ...           4 years ago
  • 4.6.2                                ...           4 years ago
  • 4.6.0                                ...           4 years ago
  • 4.5.0                                ...           4 years ago
  • 4.4.4                                ...           4 years ago
  • 4.4.3                                ...           4 years ago
  • 4.4.2                                ...           4 years ago
  • 4.4.1                                ...           4 years ago
  • 4.4.0                                ...           4 years ago
  • 4.3.0                                ...           4 years ago
  • 4.2.2                                ...           4 years ago
  • 4.2.1                                ...           4 years ago
  • 4.2.0                                ...           4 years ago
  • 4.1.7                                ...           4 years ago
  • 4.1.6                                ...           4 years ago
  • 3.1.5                                ...           4 years ago
  • 4.1.5                                ...           4 years ago
  • 4.1.4                                ...           5 years ago
  • 4.1.3                                ...           5 years ago
  • 4.1.2                                ...           5 years ago
  • 4.1.0                                ...           5 years ago
  • 3.1.4                                ...           5 years ago
  • 4.0.1                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 3.1.3                                ...           5 years ago
  • 3.1.2                                ...           5 years ago
  • 3.1.1                                ...           5 years ago
  • 3.1.0                                ...           5 years ago
  • 3.0.3                                ...           5 years ago
  • 3.0.2                                ...           5 years ago
  • 3.0.1                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.8.0                                ...           5 years ago
  • 2.7.0                                ...           5 years ago
  • 2.6.1                                ...           5 years ago
  • 2.6.0                                ...           5 years ago
  • 2.5.1                                ...           5 years ago
  • 2.5.0                                ...           5 years ago
  • 2.4.0                                ...           5 years ago
  • 2.2.0                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Downloads
Today 234
This Week 20,139
This Month 21,611
Last Day 769
Last Week 20,287
Last Month 90,357
Dependencies (26)
Dev Dependencies (49)
Dependents (597)

Copyright 2014 - 2017 © taobao.org |