Skip to content

Commit f2ce503

Browse files
committed
test&doc
1 parent 4270a10 commit f2ce503

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

docs/README.gist.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,19 @@ PutExtra是上传时的可选信息,默认为null
333333
### 云处理
334334

335335
<a云处理使用说明\>
336+
337+
#### pfop
338+
`pfop`的作用是对已存在七牛服务器上的文件做持久化的fop,具体见[api文档](http://developer.qiniu.com/docs/v6/api/overview/fop/persistent-fop.html)
339+
340+
```{javascript}
341+
// 原型
342+
func pfop(bucketName, keyName, fops, opts, callback);
343+
344+
// 例子
345+
@gist(../test/io.test.js#pfop)
346+
347+
```
348+
336349
#### 查看图像信息
337350

338351
```{javascript}

docs/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,23 @@ qiniu.rsf.listPrefix(bucketname, prefix, marker, limit, function(err, ret) {
529529
### 云处理
530530

531531
<a云处理使用说明\>
532+
533+
#### pfop
534+
`pfop`的作用是对已存在七牛服务器上的文件做持久化的fop,具体见[api文档](http://developer.qiniu.com/docs/v6/api/overview/fop/persistent-fop.html)
535+
536+
```{javascript}
537+
// 原型
538+
func pfop(bucketName, keyName, fops, opts, callback);
539+
540+
// 例子
541+
// pfop
542+
qiniu.fop.pfop(TEST_BUCKET, keys[0], 'avinfo', {notifyUrl: 'www.test.com', force: true}, function(err, ret) {
543+
ret.should.have.keys('persistentId');
544+
done();
545+
});
546+
547+
```
548+
532549
#### 查看图像信息
533550

534551
```{javascript}

qiniu/fop.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ Exif.prototype.makeRequest = function(url) {
5151
}
5252

5353

54-
function pfop(bucket, key, fops, notify, onret) {
54+
function pfop(bucket, key, fops, opts, onret) {
55+
56+
opts = opts || {};
57+
var notifyStr = '&notifyURL=' + opts.notifyURL || '';
58+
var forceStr = opts.force && '&force=1' || '';
5559

5660
var uri = 'http://api.qiniu.com/pfop/';
57-
var body = 'bucket='+bucket+'&key='+key+'&fops='+fops+'&notifyURL='+notify;
61+
var body = 'bucket='+bucket+'&key='+key+'&fops='+fops+ notifyStr + forceStr;
5862
var auth = util.generateAccessToken(uri, body);
5963
rpc.postWithForm(uri, body, auth, onret);
6064
}

test/io.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,16 @@ describe('test start step1:', function() {
133133
});
134134
});
135135
});
136+
137+
describe('pfop', function() {
138+
it('do pfop', function(done) {
139+
// @gist pfop
140+
// pfop
141+
qiniu.fop.pfop(TEST_BUCKET, keys[0], 'avinfo', {notifyUrl: 'www.test.com', force: true}, function(err, ret) {
142+
ret.should.have.keys('persistentId');
143+
done();
144+
});
145+
// @endgist
146+
})
147+
});
136148
});

0 commit comments

Comments
 (0)