Comparing version 2.4.2 to 6.0.0
@@ -1,58 +0,7 @@ | ||
#CHANGELOG | ||
## CHANGE LOG | ||
## v2.4.2 | ||
### v6.0.0 | ||
Issue [#48](https://github.com/qiniu/nodejs-sdk/pull/48): | ||
2013-07-16 issue [#56](https://github.com/qiniu/nodejs-sdk/pull/56) | ||
- 去除 auth.GetPolicy.scope 的默认值:"*/*" | ||
Issue [#46](https://github.com/qiniu/nodejs-sdk/pull/46): | ||
- 更新 v2.4.1 的文档(docs/README.md) | ||
## v2.4.1 | ||
2013-02-09 | ||
Issue [#43](https://github.com/qiniu/nodejs-sdk/pull/43): | ||
- imageMogr bugfix: auto-orient | ||
- auth.UploadToken, auth.DownloadToken 改为 auth.PutPolicy, auth.GetPolicy | ||
- auth.UploadToken.generateToken() 改为 auth.PutPolicy.token() | ||
- auth.DownloadToken.generateToken() 改为 auth.GetPolicy.token() | ||
- auth.DownloadToken.pattern 改为 auth.GetPolicy.scope | ||
## v2.4.0 | ||
2013-01-23 | ||
Issue [#36](https://github.com/qiniu/nodejs-sdk/pull/36): | ||
- 增加 auth.DownloadToken 类 | ||
- auth.UploadToken 增加:escape、asyncOps 成员,generateSignature 改名为 generateToken | ||
- 增加 rs.copy, rs.move, rs.batchGet, rs.batchStat, rs.batchDelete, rs.batchCopy, rs.batchMove | ||
- 增加 Travis-CI 的支持 | ||
Issue [#32](https://github.com/qiniu/nodejs-sdk/pull/32): | ||
- auth.UploadToken.generateSignature 各个参数调整为可选 | ||
- uploadWithToken 非兼容调整: rs.uploadWithToken(uploadToken, stream, key, mimeType, customMeta, callbackParams, crc32, onret) | ||
- generateActionString 非兼容调整: action = util.generateActionString(bucket, key, mimeType, customMeta, crc32) | ||
## v2.3.2 | ||
2012-12-31 | ||
- 修复crc32编码 | ||
- 修复使用UploadToken方式上传时流式上传bug,流式上传不检查crc32 | ||
## v2.3.0 | ||
2012-11-23 | ||
- 启用新的 uploadToken(上传凭证)上传方式,可由客户方业务服务器生成上传凭证。上传前无需请求七牛云存储,减少http请求。 | ||
- 遵循 [sdkspec v6.0.4](https://github.com/qiniu/sdkspec/tree/v6.0.4) |
13
index.js
@@ -1,9 +0,10 @@ | ||
var libpath = process.env.QINIU_COV ? './lib-cov' : './lib'; | ||
var libpath = process.env.QINIU_COV ? './lib-cov' : './qiniu'; | ||
module.exports = { | ||
conf: require(libpath + '/conf.js'), | ||
digestauth: require(libpath + '/digestauth.js'), | ||
rs: require(libpath + '/rs.js'), | ||
img: require(libpath + '/img.js'), | ||
auth: require(libpath + '/auth.js'), | ||
io: require(libpath + '/io.js'), | ||
rs: require(libpath + '/rs.js'), | ||
rsf: require(libpath + '/rsf.js'), | ||
fop: require(libpath + '/fop.js'), | ||
conf: require(libpath + '/conf.js'), | ||
}; |
{ | ||
"name": "qiniu", | ||
"version": "2.4.2", | ||
"version": "6.0.0", | ||
"description": "Node wrapper for Qiniu Resource (Cloud) Storage API", | ||
@@ -39,2 +39,6 @@ "main": "index.js", | ||
"email": "sunikbear@gmail.com" | ||
}, | ||
{ | ||
"name": "lintianzhi", | ||
"email": "lintianzhi1992@gmail.com" | ||
} | ||
@@ -46,4 +50,4 @@ ], | ||
"dependencies": { | ||
"mime": "1.2.7", | ||
"formstream": "0.0.2", | ||
"mime": "1.2.9", | ||
"formstream": "0.0.5", | ||
"crc32": "0.2.2" | ||
@@ -50,0 +54,0 @@ }, |
123
README.md
@@ -1,124 +0,33 @@ | ||
# Node wrapper for Qiniu Resource (Cloud) Storage API | ||
# Qiniu Resource Storage SDK for Node.js | ||
[![Build Status](https://travis-ci.org/qiniu/nodejs-sdk.png?branch=master)](https://travis-ci.org/qiniu/nodejs-sdk) | ||
![logo](http://qiniutek.com/images/logo-2.png) | ||
[![Qiniu Logo](http://qiniutek.com/images/logo-2.png)](http://qiniu.com/) | ||
该 SDK 适用于 NodeJS 0.4.7 及其以上版本,基于 [七牛云存储官方API](/v3/api/) 构建。若您的服务端是一个基于 NodeJS 编写的网络程序,使用此 SDK ,能让您以非常便捷地方式将数据安全地存储到七牛云存储上。以便让您应用的终端用户进行高速上传和下载,同时也使得您的服务端更加轻盈。 | ||
## 下载 | ||
jscoverage: [85%](http://fengmk2.github.com/coverage/qiniu.html) | ||
### 从 npm 安装 | ||
## 安装 | ||
这是我们建议的方式 | ||
npm install qiniu | ||
``` | ||
npm install qiniu | ||
``` | ||
### 获取 ACCESS_KEY 和 SECRET_KEY | ||
### 从 release 版本下载 | ||
要对接七牛云存储服务,您需要七牛云存储服务端颁发给您的 `ACCESS_KEY` 和 `SECRET_KEY`。`ACCESS_KEY` 用于标识客户方的身份,在网络请求中会以某种形式进行传输。`SECRET_KEY` 作为私钥形式存放于客户方本地并不在网络中传递,`SECRET_KEY` 的作用是对于客户方发起的具体请求进行数字签名,用以保证该请求是来自指定的客户方并且请求本身是合法有效的。使用 `ACCESS_KEY` 进行身份识别,加上 `SECRET_KEY` 进行数字签名,即可完成应用接入与认证授权。 | ||
下载地址:https://github.com/qiniu/nodejs-sdk/releases | ||
您可以通过如下步骤获得 `ACCESS_KEY` 和 `SECRET_KEY`: | ||
这里可以下载到旧版本的SDK,release 版本有版本号,有 [CHANGELOG](https://github.com/qiniu/nodejs-sdk/blob/develop/CHANGELOG.md),使用规格也会比较稳定。 | ||
1. [开通七牛开发者帐号](https://dev.qiniutek.com/signup) | ||
2. [登录七牛开发者自助平台,查看 ACCESS_KEY 和 SECRET_KEY](https://dev.qiniutek.com/account/keys) | ||
### 从 git 库下载 | ||
获取到 `ACCESS_KEY` 和 `SECRET_KEY` 之后,您就可以参考下面的示例代码进行接入使用了。 | ||
你可以直接用 git clone 下载源代码来使用。但是请注意非 master 分支的代码在规格上可能承受变更,应谨慎使用。 | ||
## 使用 | ||
SDK 使用文档参考:[http://docs.qiniutek.com/v3/sdk/nodejs/](http://docs.qiniutek.com/v3/sdk/nodejs/) | ||
参考文档:[七牛云存储 Node.js SDK 使用指南](https://github.com/qiniu/nodejs-sdk/tree/develop/docs) | ||
### 示例程序 | ||
旧版本的SDK(version < 6.0.0) [戳这里](http://docs.qiniutek.com/v3/sdk/nodejs/) | ||
var qiniu = require('qiniu'); | ||
// 配置密钥 | ||
qiniu.conf.ACCESS_KEY = '<Please apply your access key>'; | ||
qiniu.conf.SECRET_KEY = '<Dont send your secret key to anyone>'; | ||
// 实例化带授权的 HTTP Client 对象 | ||
var conn = new qiniu.digestauth.Client(); | ||
// 创建空间,也可以在开发者自助网站创建 | ||
var bucket = 'yet_another_bucket'; | ||
qiniu.rs.mkbucket(conn, bucket, function(resp) { | ||
console.log("\n===> Make bucket result: ", resp); | ||
if (resp.code != 200) { | ||
return; | ||
} | ||
}); | ||
// 实例化 Bucket 操作对象 | ||
var rs = new qiniu.rs.Service(conn, bucket); | ||
// 上传文件第1步 | ||
// 生成上传授权凭证(uploadToken) | ||
var opts = { | ||
scope: "yet_another_bucket", // 可以是 "<bucketName>" 或 "<bucketName>:<key>" | ||
expires: 3600, | ||
callbackUrl: "http://www.example.com/notifications/qiniurs", // 可选 | ||
callbackBodyType: "application/x-www-form-urlencoded", // 可选 | ||
}; | ||
var uploadPolicy = new qiniu.auth.PutPolicy(opts); | ||
var uploadToken = uploadPolicy.token(); | ||
// 上传文件第2步 | ||
// 组装上传文件所需要的参数 | ||
var key = __filename; | ||
var localFile = key, | ||
customMeta = "", | ||
callbackParams = {"bucket": bucket, "key": key}, | ||
enableCrc32Check = false, | ||
mimeType = mime.lookup(key); | ||
// 上传文件第3步 | ||
// 上传文件 | ||
rs.uploadFileWithToken(uploadToken, localFile, key, mimeType, customMeta, callbackParams, enableCrc32Check, function(resp){ | ||
console.log("\n===> Upload File with Token result: ", resp); | ||
if (resp.code != 200) { | ||
// ... | ||
return; | ||
} | ||
// 查看已上传文件属性信息 | ||
rs.stat(key, function(resp) { | ||
console.log("\n===> Stat result: ", resp); | ||
if (resp.code != 200) { | ||
// ... | ||
return; | ||
} | ||
}); | ||
}); | ||
// 获取文件下载链接(含文件属性信息) | ||
var saveAsFriendlyName = key; | ||
rs.get(key, saveAsFriendlyName, function(resp) { | ||
console.log("\n===> Get result: ", resp); | ||
if (resp.code != 200) { | ||
// ... | ||
return; | ||
} | ||
}); | ||
// 删除已上传文件 | ||
rs.remove(key, function(resp) { | ||
console.log("\n===> Delete result: ", resp); | ||
}); | ||
// 将bucket的内容作为静态内容发布 | ||
var DEMO_DOMAIN = bucket + '.dn.qbox.me'; | ||
rs.publish(DEMO_DOMAIN, function(resp){ | ||
console.log("\n===> Publish result: ", resp); | ||
if (resp.code != 200){ | ||
clear(rs); | ||
return; | ||
} | ||
}); | ||
// 删除bucket,慎用! | ||
rs.drop(function(resp){ | ||
console.log("\n===> Drop result: ", resp); | ||
}); | ||
## 贡献代码 | ||
@@ -134,3 +43,3 @@ | ||
Copyright (c) 2012 qiniutek.com | ||
Copyright (c) 2013 qiniu.com | ||
@@ -137,0 +46,0 @@ 基于 MIT 协议发布: |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
13
0
18176
517
48
4
+ Addedformstream@0.0.5(transitive)
+ Addedmime@1.2.9(transitive)
- Removedformstream@0.0.2(transitive)
Updatedformstream@0.0.5
Updatedmime@1.2.9