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

up2oss

v1.6.2

Published

A faster, lighter oss upload component

Downloads

3

Readme

UP2OSS

一个灵巧、快捷和方便的 oss 上传中间件

安装

npm install up2oss

使用

初始化配置

EXPRESS 项目推荐使用 app.js 配置,示例如下:

const { UP2OSS } = require("up2oss");
const up2oss = new UP2OSS({
	accessKeyId: "your accessKeyId",
	accessKeySecret: "your accessKeySecret",
	bucket: "your bucket",
	region: "your region"
});

// 全局路由
app.use(up2oss.upload);

// 指定路由
app.use("/upload", up2oss.upload);

获取 OSS 上传结果

通过路由回调函数参数 req 获取相应结果。

参数说明:

  1. req.attachments: 上传文件列表
  2. req.fields: 上传字段列表

| 对象 | 字段 | 描述 | | ----------- | ------- | ------------ | | attachments | name | 文件名 | | attachments | size | 文件大小 | | attachments | url | OSS 文件地址 | | fields | name | 字段名 | | fields | content | 字段值 |

示例:

router.post("/api/upload", (req, res) => {
	console.log("upload info: ", {
		attachments: req.attachments,
		fields: req.fields
	});
	res.end("upload successfully");
});

其他说明

  • 如何自定义文件夹?

    1. 通过参数 path 设置,默认为 bucket 根目录。
    2. 初始化配置设置是全局属性,所有上传路由均生效。
    3. FORM 表单设置是局部属性,仅当前路由生效。
    4. 两者同时设置时优先级:表单参数 > 初始化参数
  • 如何设置文件是否覆盖?

    1. 通过参数 ow 设置,默认为 false
    2. 设置方法与 path设置相似 。