diff --git a/CHANGELOG.md b/CHANGELOG.md index 82612333..30aa8d89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ #CHANGELOG +## v2.4.3 + +2013-02-22 + +Issue [#54](https://github.com/qiniu/nodejs-sdk/pull/54): + +- 去除对自定义 generateQueryString() 函数的依赖,使用 querystring 包的 stringify() 函数。 +- auth.PutPolicy 增加对 returnBody 的支持,用户可自定义上传完文件后的返回值。 + ## v2.4.2 Issue [#48](https://github.com/qiniu/nodejs-sdk/pull/48): diff --git a/lib/auth.js b/lib/auth.js index 84f33c55..7fa9cdde 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -43,6 +43,7 @@ function PutPolicy(opts) { this.customer = opts.customer || null; this.escape = opts.escape || 0; this.asyncOps = opts.asyncOps || null; + this.returnBody = opts.returnBody || null; } PutPolicy.prototype.token = function() { @@ -67,6 +68,9 @@ PutPolicy.prototype.token = function() { if (this.escape) { params["escape"] = this.excape; } + if (this.returnBody !== null) { + params["returnBody"] = this.returnBody; + } return generateToken(params); }; diff --git a/lib/rs.js b/lib/rs.js index 2e12d51e..3c306483 100644 --- a/lib/rs.js +++ b/lib/rs.js @@ -3,6 +3,7 @@ var path = require('path'); var crc32 = require('crc32'); var mime = require('mime'); var formstream = require('formstream'); +var querystring = require('querystring'); var config = require('./conf.js'); var util = require('./util.js'); var img = require('./img.js'); @@ -135,7 +136,7 @@ Service.prototype.uploadWithToken = function(uploadToken, stream, key, mimeType, "mime_type": mimeType }; } - var callbackQueryString = util.generateQueryString(callbackParams); + var callbackQueryString = querystring.stringify(callbackParams); var url = config.UP_HOST + "/upload"; var filename = path.basename(key); diff --git a/lib/util.js b/lib/util.js index bc81a9dc..387c149d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -34,21 +34,6 @@ exports.generateActionString = function(bucket, key, mimeType, customMeta, crc32 return actionParams; } -exports.generateQueryString = function (params) { - if (params.constructor === String) { - return params; - } - var total_params = []; - for (var key in params) { - total_params.push(escape(key) + "=" + escape(params[key])); - } - if (total_params.length > 0) { - return total_params.join("&"); - } else { - return ""; - } -} - // ------------------------------------------------------------------------------------------ // func readAll diff --git a/package.json b/package.json index 868e5802..290ec119 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qiniu", - "version": "2.4.2", + "version": "2.4.3", "description": "Node wrapper for Qiniu Resource (Cloud) Storage API", "main": "index.js", "directories": {