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 🙏

© 2025 – Pkg Stats / Ryan Hefner

qcloud-cos-upload

v1.3.2

Published

上传单个文件到腾讯云COS服务

Readme

qcloud-cos-upload

npm version Build Status semantic-release

上传单个文件到腾讯云COS服务,用于静态文件上传。

releases and changelog

Tips

适配腾讯云官方 COS Nodejs SDK(XML API) cos-nodejs-sdk-v5

批量上传文件参见 gulp-qcloud-cos-upload

为安全起见,建议为每个存储桶提供独立的子账号,使用子账号的 SecretId 和 SecretKey 来上传文件。

创建子账号

在存储桶配置的权限管理页卡配置存储桶访问权限Policy权限设置,提供子账号的访问权限。

Getting Started

安装:

npm i qcloud-cos-upload

选项配置参见 腾讯云存储说明文档

使用:

const upload = require('qcloud-cos-upload');

upload({
  // 是否开启调试模式,默认为 false,调试模式下,报错时输出详细错误信息
  debug: false,
  // 是否在控制台打印上传日志,默认为 true
  log: true,
  // 是否允许文件覆盖,默认为 false
  overwrite: false,
  // 为 true 则输出文件路径为腾讯云默认 CDN 地址。为具体域名,则替换腾讯云默认 CDN 域名。
  cdn: '',
  // 文件远程路径协议,默认为 'https:',这个选项仅影响输出结果。
  protocol: 'https:',
  // 在腾讯云申请的 AppId
  AppId: '1000000000',
  // 配置腾讯云 COS 服务所需的 SecretId
  SecretId: 'AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  // 配置腾讯云 COS 服务所需的 SecretKey
  SecretKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  // COS服务配置的存储桶名称
  Bucket: 'static',
  // 地域名称
  Region: 'ap-chengdu',
  // 要上传的本地文件路径
  FilePath: './1.zip',
  // 文件在存储桶中的路径
  Key: '1.zip'
}).then(rs => {
  // 线上路径
  console.info(rs.url);
  // 为 true 表明线上文件已存在
  console.info(rs.isExists);
  // 为 true 表明进行了覆盖
  console.info(rs.overwrited);
  // 为 true 表明已进行了上传
  console.info(rs.uploaded);
  // 文件在对象存储的线上访问路径
  console.info(rs.cosUrl);
  // 文件在 CDN 的线上访问路径,如果没有配置 cdn 选项则为 undefined
  console.info(rs.cdnUrl);
  // 如果进行了上传,可以通过 uploadData 取得详细上传信息
  console.info(rs.uploadData);
});