aliyun OSS(Open Storage Service) lib. A node wrapper for OSS RESTful API.
Install
npm install kloud --save
Usage
First, create an OSS client:
var client =kloud.createClient({
accessKeyId:'<your access key id>',
accessKeySecret:'<your access key secret>',
host:'<your bucket host>',// region.aliyuncs.com
bucket:'<your bucket name>'
});
PUT
Use the Client#put(filename, headers) method with a string or buffer to upload some strings to OSS, just like node http.Client request. Return a duplex stream, you can listen for a response event on it, and write the content using req.end(content).
var str =JSON.stringify({ foo:'bar'});
var req =client.put('test.json',{
'Content-Type':'application/json',
'Content-Length':str.length
});
req.on('response',function(res){
if(res.statusCode===200){
console.log('file saved.');
}
});
req.end(str);
Use the Client#putFile(src, filename, headers, callback) to upload a file to OSS: