Skip to content

Commit 329159b

Browse files
committed
querystring
1 parent 4556dab commit 329159b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

qiniu/fop.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var util = require('./util');
22
var rpc = require('./rpc');
33

4+
var querystring = require('querystring');
5+
46
exports.ImageView = ImageView;
57
exports.ImageInfo = ImageInfo;
68
exports.Exif = Exif;
@@ -54,11 +56,23 @@ Exif.prototype.makeRequest = function(url) {
5456
function pfop(bucket, key, fops, opts, onret) {
5557

5658
opts = opts || {};
57-
var notifyStr = '&notifyURL=' + opts.notifyURL || '';
58-
var forceStr = opts.force && '&force=1' || '';
59+
60+
param = {
61+
bucket: bucket,
62+
key: key,
63+
fops: fops
64+
};
65+
if (opts.notifyURL) {
66+
param.notifyURL = opts.notifyURL;
67+
} else {
68+
param.notifyURL = 'www.test.com';
69+
}
70+
if (opts.force) {
71+
param.force = 1;
72+
}
5973

6074
var uri = 'http://api.qiniu.com/pfop/';
61-
var body = 'bucket='+bucket+'&key='+key+'&fops='+fops+ notifyStr + forceStr;
75+
var body = querystring.stringify(param);
6276
var auth = util.generateAccessToken(uri, body);
6377
rpc.postWithForm(uri, body, auth, onret);
6478
}

test/io.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe('test start step1:', function() {
138138
it('do pfop', function(done) {
139139
// @gist pfop
140140
// pfop
141-
qiniu.fop.pfop(TEST_BUCKET, keys[0], 'avinfo', {notifyUrl: 'www.test.com', force: true}, function(err, ret) {
141+
qiniu.fop.pfop(TEST_BUCKET, keys[0], 'avinfo', {notifyURL: 'www.test.com'}, function(err, ret) {
142142
ret.should.have.keys('persistentId');
143143
done();
144144
});

0 commit comments

Comments
 (0)