Package Exports
- ali-oss
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ali-oss) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ali-oss
aliyun OSS(open storage service) node client. generator friendly.
a node.js wrapper for OSS restful api
Install
npm install ali-ossUsage
Init
init a oss client, need accessKeyId, accessKeySecret and bucket
var OSS = require('ali-oss');
var client = OSS.create({
accessKeyId: 'id',
accessKeySecret: 'xxx',
bucket: 'test'
});options:
- accessKeyId
- accessKeySecret
- [host]: default to
oss.aliyuncs.com:8080 - [timeout]: default to '10s'
Methods
upload
yield* client.upload(file, name, options);options:
- file: can be filepath, fileContent, stream
- name: object name in oss
- options:
- timeout: request timeout
- headers: custom headers, checkout the doc
get
yield* client.get(name, path, options);options:
- name: object name in oss
- path: can be filepath and stream
- options:
- timeout
- headers
remove
yield* client.remove(name, options);options:
- name: object name in oss
- options:
- timeout
no generator support
if you do not use node v0.11+ or do not use node --harmony.
this module will use regenerator to convert to es5 style.
so you only need to use co wrap the generator function into callback style:
var co = require('co');
var OSS = require('ali-oss');
var client = OSS.create({});
client.update = co(client.update);
client.get = co(client.get);
client.remove = co(client.remove);then you use these APIs as common async callback APIs. checkout the callback_example.js.
License
MIT