Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aliyun-oss

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aliyun-oss

a new version of oss-client

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

NPM version License Dependency status

aliyun-oss

  • node.js sdk for aliyun oss.
npm install aliyun-oss

aliyun oss

aliyun oss document

how to use

const OSS = require('aliyun-oss')
const 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
 */

const 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) {});

with webpack

add node stuff in your webpack.config.js

{
  node: {
    fs: 'empty'
  }
}

License

MIT

Keywords

FAQs

Package last updated on 15 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc