Skip to content
an aliyun oss service client for nodejs, exposes api more like nodejs.fs
CoffeeScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
src
.gitignore
.jshintrc
LICENSE
README.md
package.json
test
tests

README.md

oss-easy

an aliyun oss service client for nodejs, exposes api more like the file system module of Node.JS 一个阿里云 OSS 服务的 Node.JS 模块,提供类似 fs 的 API。同时提供一些方便的批量操作方法

Documentation

Init bucekt client instance

OssEasy = require("oss-easy")
ossOptions = {
  accessKeyId : "your oss key"
  accessKeySecret : "your oss secret"
}
var oss = new OssEasy(ossOptions, "bucket_name");

Write data to bucket

oss.writeFile('remote/path/to/filename', 'content could be string of buffer', function(err) {
    if(err) console.log(err);
});

Upload a local file to bucket

oss.uploadFile('path_to_local_file', 'remote/path/to/filename', function(err) {
    if(err) console.log(err);
});

Upload multiple local files to bucket in one batch

var tasks = {
  'local/path/to/filename0': "remote/path/to/filename0",
  'local/path/to/filename1': "remote/path/to/filename1",
  'local/path/to/filename2': "remote/path/to/filename2",
};
oss.uploadFiles(tasks, function(err) {
    if(err) console.log(err);
});

Download a file from bucket

oss.downloadFile('remote/path/to/filename', 'path_to_local_file', 'function(err) {
    if(err) console.log(err);
});

Download multiple files from bucket

var tasks = {
  "remote/path/to/filename0": 'local/path/to/filename0',
  "remote/path/to/filename1": 'local/path/to/filename1',
  "remote/path/to/filename2": 'local/path/to/filename2',
};

oss.downloadFiles(tasks, function(err) {
    if(err) console.log(err);
});

Delete a file from the bucekt

oss.deleteFile(filename, function(err) {
    if(err) console.log(err);
});

Delete all remote files under a given folder path

oss.deleteFolder('remote/path/to/folder', function(err) {
    if(err) console.log(err);
})

Delete multiple remote files from bucket in one batch

oss.deleteFiles(['remote/path/to/filename0','remote/path/to/filename1'], function(err) {
    if(err) console.log(err);
});

Test

mocha tests

License

Copyright (c) 2013 yi Licensed under the MIT license.

Something went wrong with that request. Please try again.