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 🙏

© 2026 – Pkg Stats / Ryan Hefner

aliyun-oss-sdk-wx

v2.1.0

Published

Aliyun OSS SDK for WeChat Mini Program

Readme

aliyun-oss-sdk-wx

微信小程序 OSS SDK(npm 包)。

定位:面向业务项目直接接入,提供 Browser.js 核心对象 API(对象上传/下载/分片/签名 URL)。

QuickStart

1. 安装

npm install aliyun-oss-sdk-wx

2. 小程序工程启用 npm

在微信开发者工具中:

  1. 勾选「使用 npm 模块」
  2. 点击「工具 -> 构建 npm」

3. 初始化客户端

import Client from 'aliyun-oss-sdk-wx'

const client = new Client({
  bucket: 'your-bucket',
  endpoint: 'oss-cn-hangzhou.aliyuncs.com',
  accessKeyId: 'your-ak',
  accessKeySecret: 'your-sk',
  stsToken: 'your-sts-token',
  timeout: 60000,
  retryMax: 1,
  refreshSTSTokenInterval: 300,
  refreshSTSToken: async () => {
    // 从你的业务服务端获取最新 STS
    const sts = await getSTSFromServer()
    return {
      accessKeyId: sts.accessKeyId,
      accessKeySecret: sts.accessKeySecret,
      stsToken: sts.stsToken,
    }
  },
})

如果你的项目使用 require

const Client = require('aliyun-oss-sdk-wx').default

Example

示例 1:直传(put)

const choose = await wx.chooseMedia({
  count: 1,
  mediaType: ['image', 'video'],
})

const file = choose.tempFiles[0]

const result = await client.put('uploads/demo.mp4', {
  path: file.tempFilePath,
  size: file.size,
  mime: file.type,
})

console.log('url:', result.url)
console.log('etag:', result.etag)

示例 2:分片上传(multipartUpload)

const choose = await wx.chooseMedia({
  count: 1,
  mediaType: ['video'],
})

const file = choose.tempFiles[0]
let checkpoint: any = null

const result = await client.multipartUpload(
  'videos/big-file.mp4',
  {
    path: file.tempFilePath,
    size: file.size,
    mime: file.type,
  },
  {
    partSize: 1024 * 1024, // 1MB
    parallel: 3,
    progress: async (percent, cp) => {
      checkpoint = cp || checkpoint
      console.log('progress:', Math.floor(percent * 100) + '%')
    },
  },
)

console.log('done:', result.name, result.etag)

// 取消上传
// client.cancel()

// 断点续传(复用 checkpoint)
// await client.multipartUpload('videos/big-file.mp4', {
//   path: file.tempFilePath,
//   size: file.size,
//   mime: file.type,
// }, {
//   checkpoint,
// })

Apis

Client 构造参数(new Client(options)

  • bucket: string 目标 Bucket
  • endpoint: string OSS Endpoint(支持带/不带协议)
  • accessKeyId: string
  • accessKeySecret: string
  • stsToken?: string
  • secure?: boolean 默认 true
  • cname?: boolean 是否使用 CNAME
  • timeout?: number 请求超时(ms)
  • retryMax?: number 请求重试次数
  • headers?: Record<string, string | number | boolean>
  • refreshSTSToken?: () => Promise<{ accessKeyId; accessKeySecret; stsToken }>
  • refreshSTSTokenInterval?: number 刷新间隔(秒)

对象操作

  • put(name, file, options?)
  • append(name, file, options?)
  • get(name, fileOrOptions?, options?)
  • head(name, options?)
  • delete(name, options?)
  • deleteMulti(names, options?)
  • copy(name, sourceName, sourceBucketOrOptions?, options?)
  • list(query?, options?)
  • listV2(query?, options?)
  • getObjectUrl(name)
  • generateObjectUrl(name)

签名 URL

  • signatureUrl(name, options?, strictObjectNameValidation?)
  • asyncSignatureUrl(name, options?, strictObjectNameValidation?)

分片上传

  • initMultipartUpload(name, options?)
  • uploadPart(name, uploadId, partNo, file, start, end, options?)
  • completeMultipartUpload(name, uploadId, parts, options?)
  • listParts(name, uploadId, query?, options?)
  • listUploads(query?, options?)
  • abortMultipartUpload(name, uploadId, options?)
  • multipartUpload(name, file, options?)

任务控制

  • cancel(abort?)
  • isCancel()
  • resetCancelFlag()
  • useBucket(name)
  • currentOptions

输入文件类型

file 支持:

  • string(本地临时文件路径)
  • ArrayBuffer
  • Uint8Array
  • { path: string; size?: number; mime?: string }

说明

  • 当前仅覆盖 Browser.js 核心对象 API,不包含 Bucket 管理、RTMP、ImageClient。