node-ali-oss
v0.0.2
Published
aliyun oss(open storage service) node client use es5
Downloads
2
Readme
node-ali-oss
安装
npm install node-ali-oss
使用
构造对象
var OSS = require('node-ali-oss');
var options = {
bucket: 'node-ali-oss',
accessKeyId: 'iAeyzYXtZAdM8V2V',
accessKeySecret: 'AmieMAD5ZYuevL3UNrkeORzQ0cvqrO'
}
var client = OSS(options);
options:
- accessKeyId
- accessKeySecret
- [host]: default to
oss.aliyuncs.com:8080
update
client.upload(file, name, cb)
options:
- file: can be filepath, fileContent, stream
- name: object name in oss
get
client.get(name, cb)
options:
- name: object name in oss
remove
client.remove(name, cb)
例子
path = require 'path'
fs = require 'fs'
OSS = require 'node-ali-oss'
options =
bucket: 'node-ali-oss',
accessKeyId: 'iAeyzYXtZAdM8V2V',
accessKeySecret: 'AmieMAD5ZYuevL3UNrkeORzQ0cvqrO'
client = OSS options
file = path.join __dirname, '../package.json'
ossFilename = 'node-ali-oss-package.json'
client.upload file, ossFilename, (err, info)->
return console.log err if err
client.get ossFilename, (err, info)->
return console.log err if err
console.log info.toString()
client.remove ossFilename, (err, info)->
console.log err, info