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

egg-alioss

v0.0.2

Published

Ali-oss plugin for egg

Downloads

6

Readme

egg-alioss

node version NPM version npm download

该插件基于ali-oss,在将其封装到egg的基础上还进行了简单的扩展

安装

npm i egg-alioss

使用方式

// config/plugin.js
exports.alioss = {
  enable: true,
  package: 'egg-alioss',
};
// {app_root}/config/config.default.js
exports.alioss = {
  client: {
    accessKeyId: 'your access key',
    accessKeySecret: 'your access secret',
    bucket: 'your bucket',
    endpoint: 'oss-cn-xxx.aliyun.com',
  },
};


// {app_root}/app/****.js
const alioss = app.alioss;

const info = alioss.getUploadToken('abc', 500, []);

更多用法参见ali-oss

扩展方法

getCallbackMD5(ctx)

  • 获取回调文件的MD5信息
  • ctx是egg.js的controller实例
  • 返回上传文件的MD5

getCallbackJson(url, params, bodyType)

  • 计算并获得回调配置
  • params是回调时附带的参数JSON,参数值为特定字符串则会被替换为相应内容。
  • bodyType可以在application/x-www-form-urlencoded和里二选一
  • 返回一个JSON,可以用于getUploadToken

params一览

$bucket	 存储空间
$object  对象(文件)
$etag  文件的ETag,即返回给用户的ETag字段
$size  Object大小,CompleteMultipartUpload时为整个Object的大小
$mimeType  资源类型,例如jpeg图片的资源类型为image/jpeg
$imageInfo.height  图片高度
$imageInfo.width  图片宽度
$imageInfo.format  图片格式,例如jpg、png等

getUploadToken(dir, timeout = 600, options = null, callback = null)

  • 计算并获取上传凭证并提供给前端
  • dir是限制上传的目录
  • timeout是凭证有效时间
  • options是额外选项
  • callback是回调配置,一般通过getCallbackJson获得
  • 返回一个JSON,可以用于getUploadToken

options一览

maxLength 限制文件最大长度,单位字节
filename 限制文件名

扩展配置

callbackHost

回调服务器的地址

License

MIT