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

qiniu-dir-uploader

v1.2.4

Published

A directory uploader for Qiniu

Downloads

12

Readme

qiniu-dir-uploader

A directory uploader for Qiniu. 上传一个文件夹中的所有文件到七牛,并保持目录结构

Install

  yarn add qiniu-dir-uploader -D
  #or
  npm i qiniu-dir-uploader --save-dev

Usage

upload.js

var path=require('path');
var qiniu=require('qiniu');
var QiniuDirUploader=require('qiniu-dir-uploader');
var option={
  secretKey:'secretKey',
  accessKey:'accessKey',
  bucket:'bucket',
  excludes:['.html'],
  buildAssetsRoot:path.join(__dirname,'./dist'),
  publishAssetsRoot:'root',
  loggerCategory:'upload',
  zone:qiniu.zone.Zone_z0,
  removeBeforeUpload:true,
  refresh:true,
  prefetch:2,
  https:true,
  host:'cdn.qiniu.com',
    keep:false
};

var uploader=QiniuDirUploader.getUploader(option);
//or
var uploader=new QiniuDirUploader(option);

//start upload
uploader.upload();

package.json

{
  "scripts":{
    "build": "node build.js",
    "postbuild": "node upload.js",
    "upload":"node upload.js"
  }
}
yarn run build
#or
yarn run upload

参数说明

七牛相关参数的详细说明,请看七牛文档

interface UploadOption {
  /**
   * 空间名
   */
  bucket: string;

  /**
   * accessKey
   */
  accessKey: string;
  /**
   * secretKey
   */
  secretKey: string;
  /**
   * 要排除的文件后缀名
   */
  excludes: string[];
  /**
   * 打包资源根目录
   * @example "D:\\dev\\project\\dist"
   */
  buildAssetsRoot: string;
  /**
   * 发布资源根目录,(即七牛上的目录)
   * @example "app"
   */
  publishAssetsRoot: string;

  /**
   * log4js category,默认:upload
   */
  loggerCategory?: string;

  /**
   * 机房位置,默认华东
   */
  zone?:string;
   /**
   * 上传前是否删除同名文件,默认不删除
   */
  removeBeforeUpload?:boolean;
  /** 上传完成后是否刷新缓存 ,默认不刷新*/
  refresh?:boolean;
  /** 是否预取文件,默认不预取,1 :上传完成后预取,2:刷新后预取*/
  prefetch?:1|2;
  /** 
   * 对应的CDN空间域名。如果需要刷新缓存或是预取文件,则不能为空 
   * @example cdn.qiniu.com
   **/
  host?:string;
  /** 
   * 刷新或预取文件时,是否同时刷新或预取https 
   * @default false
   **/
  https?:boolean;
  /**
   * 是否开启调式模式,调式模式下,会打印出所有七牛接口的响应信息
   * @default false
   */
  debugger?:boolean;
    /**
     * 上传时,是否保持目录结构,默认保持
     * @default true
     */
  keep?:boolean;
}