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

node-qiniuio

v1.1.3

Published

IO lib for qiniu cdn

Downloads

8

Readme

node-qiniuio

qiniu云存储API封装

安装

npm install node-qiniuio

APIS

  • config (配置接口所需参数)
  • getFileInfo (获取云端文件信息)
  • upload (上传文件)
  • uploadCb (上传文件&回调)
  • download (获取文件下载地址)
  • delete (删除文件)
  • move (移动文件)

Examples

config

配置操作qiniuAPI所需变量,其中 ACCESS_KEY,SECRET_KEY,BUCKET_NAME为必选项

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');

/**
* 配置变量,调用不同API,需要配置不同变量
* 其中 ACCESS_KEY,SECRET_KEY,BUCKET_NAME为必选项
* ACCESS_KEY: 访问密钥
* SECRET_KEY: 密钥
* BUCKET_NAME: 空间名称
*/
qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

getFileInfo

获取文件信息API

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

/**
* @param {String} key qiniu对象实例
* @param {Function} callback 获取文件信息后回调
*/
qiniuio.getFileInfo('filename.png', function (err, rs){
    if(err) {
       //出错处理逻辑
    }
    // rs为文件信息对象
});

upload

上传文件API

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');
var filepath = '/Users/schoeu/Downloads/svn/test';

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

/**
 * @param key {String} 上传后的文件名
 * @param filePath {String} 上传文件的本地路径
 * @param callback {Function} 成功后的回调
 * @param fail {Function} 执行失败后的回调
 * @return {Undefined}
 */

qiniuio.upload('filename.png',filepath, function (rs){
    // rs为文件上传成功后信息
}, function (err){
    // 上传失败后回调,可选.err为错误对象
});

uploadCb

上传&回调API

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');
var filepath = '/Users/schoeu/Downloads/svn/test';

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name",
  "CALLBACK_URL": "http://youdomain/callback",
});

/**
 * @param key {String} 上传后的文件名
 * @param filePath {String} 上传文件的本地路径
 * @param callback {Function} 成功后的回调
 * @param fail {Function} 执行失败后的回调
 * @return {Undefined}
 */

qiniuio.uploadCb('filename.png',filepath, function (rs){
    // rs为文件上传成功后信息
}, function (err){
    // 上传失败后回调,可选.err为错误对象
});

download

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

/**
 * @param {String} url 保存在空间的文件名
 * @param {String} flag 是否返回相对路径
 * @return {String} download URL
 */

// return "path/xxxx.png"
// var downloadUrl = qiniuio.download('filename.png');

// return "youdomain.com/path/xxxx.png"
var downloadUrl = qiniuio.download('filename.png', false);

copy

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

/**
 * @param {String} key 需要移动文件的文件名
 * @param {String} dstbucket 目标空间名
 * @return {String} dstkey 目标文件名
 * @return {Function} callback 成功回调,可选
 * @return {Function} fail 失败回调,可选
 */
qiniuio.copy('filename.png', 'otherbucket', filename1.png, success, fail);

// 成功回调 可选
function success(rs){
    // 复制成功后文件信息对象
}

// 失败回调 可选
function fail(err){
    // err 错误对象
}

delete

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

/**
 * @param {String} key 需要删除的文件名
 * @return {Function} callback 成功回调
 * @return {Function} fail 失败回调
 */
qiniuio.delete('filename.png', success, fail);

// 成功回调 可选
function success(rs){
    // 删除成功后文件信息对象
}

// 失败回调 可选
function fail(err){
    // err 错误对象
}

move

// 引入node-qiniuio模块
var qiniuio = require('node-qiniuio');

qiniuio.config({
  "ACCESS_KEY" : "your_access_key",
  "SECRET_KEY" : "your_secret_key",
  "BUCKET_NAME": "your_bucket_name"
});

/**
 * @param {String} key 需要移动文件的文件名
 * @param {String} dstbucket 目标空间名
 * @return {String} dstkey 目标文件名
 * @return {Function} callback 成功回调,可选
 * @return {Function} fail 失败回调,可选
 */
qiniuio.move('filename.png', 'otherbucket', filename1.png, success, fail);

// 成功回调 可选
function success(rs){
    // 移动成功后文件信息对象
}

// 失败回调 可选
function fail(err){
    // err 错误对象
}

License

(The MIT License)

Copyright (c) 2010-2013 Will Wen Gunn <[email protected]> and other contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.