npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aliyun-oss-fork

v1.2.0

Published

a new version of oss-client

Downloads

2

Readme

NPM version License Dependency status

aliyun-oss

node.js sdk for aliyun oss, friendly with co, koa ...

npm install aliyun-oss

aliyun oss

aliyun oss document

how to use

var OSS = require('aliyun-oss');
var option = {
  accessKeyId: 'your access key id',
  accessKeySecret: 'your access key secret'
};

/*
 * 可选 option
 *
 * host:    default is: oss-cn-hangzhou.aliyuncs.com,
 * timeout: default is: 300000,
 * agent:   default is: agent.maxSockets = 20
 */

var oss = OSS.createClient(option);

summary

params

  • bucket - bucket name
  • object - object name
  • acl - bucket 访问规则, 可选值: 'private', 'public-read', 'public-read-write'
  • headers - header

callback params

  • error - error
  • res - a wrapper of http response, contain status, headers, body

object

创建object

/*
 * source:  上传的文件, 可以是文件路径、 buffer、 stream
 * headers: 可选,用户自定义 header,如: x-oss-meta-location
 *          当上传方式为: buffer 或者 stream, 建议添加 'Content-Type'(此时无法根据扩展名判断)
 */

oss.putObject({
  bucket: '',
  object: '',
  source: '',
  headers: {
    // optional
    'Content-Length': 1024
  }
}, function (err, res) {
  console.log(res.objectUrl);
});

复制object

oss.copyObject({
  bucket: '',
  object: '',
  sourceBucket: '',
  sourceObject: ''
}, function (err, res) {});

删除object

oss.deleteObject({
  bucket: '',
  object: ''
}, function (err, res) {});

批量删除objects

oss.deleteObjects({
  quiet: true, // optional, default is false
  bucket: '',
  objects: ['']
}, function (err, res) {});

获取object

/*
 * dest: 保存object的文件路径 或者 writeStream
 * headers: 可选,object类型,用户自定义header,如: If-Unmodified-Since
 */

oss.getObject({
  bucket: '',
  object: '',
  dest: '',
  headers: {}
}, function (err, res) {});

获取object头信息

oss.headObject({
  bucket: '',
  object: ''
}, function (err, res) {});

获取object列表

/*
 * prefix:    可选,object 前缀
 * marker:    可选,列表起始object
 * delimiter: 可选,object分组字符,若'/'为则不列出路径深度大于等于二层的object。
 * maxKeys:   可选,列出的object最大个数
 */

oss.listObject({
  bucket: '',
  prefix: '',
  marker: '',
  delimiter: '',
  maxKeys: ''
}, function (err, res) {});

bucket

列举bucket

oss.listBucket(function (err, res) {});

创建bucket

oss.createBucket({
  bucket: '',
  acl: ''
}, function (err, res) {});

删除bucket

oss.deleteBucket({
  bucket: ''
}, function (err, res) {});

获取bucket访问规则

oss.getBucketAcl({
  bucket: ''
}, function (err, res) {});

设置bucket访问规则

oss.setBucketAcl({
  bucket: '',
  acl: ''
}, function (err, res) {});

use with co or koa

var option = {
  wrapper: 'thunk', // or: promise
  accessKeyId: '',
  accessKeySecret: ''
};

var oss = OSS.createClient(option);

// in co or koa
yield oss.listBucket();

with webpack

add node stuff in your webpack.config.js

{
  node: {
    "fs": "empty"
  }
}

test

Coverage: 96%

License

MIT