Skip to content

Commit fabd6e4

Browse files
committed
Merge pull request #98 from lintianzhi/feature/pfop
Feature/pfop
2 parents 0aa26b8 + 329159b commit fabd6e4

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
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
@@ -530,6 +530,23 @@ qiniu.rsf.listPrefix(bucketname, prefix, marker, limit, function(err, ret) {
530530
### 云处理
531531

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

535552
```{javascript}

qiniu/fop.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
var util = require('./util');
2+
var rpc = require('./rpc');
13

4+
var querystring = require('querystring');
25

36
exports.ImageView = ImageView;
47
exports.ImageInfo = ImageInfo;
58
exports.Exif = Exif;
9+
exports.pfop = pfop;
610

711
function ImageView(mode, width, height, quality, format) {
812
this.mode = mode || 1;
@@ -49,3 +53,27 @@ Exif.prototype.makeRequest = function(url) {
4953
}
5054

5155

56+
function pfop(bucket, key, fops, opts, onret) {
57+
58+
opts = opts || {};
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+
}
73+
74+
var uri = 'http://api.qiniu.com/pfop/';
75+
var body = querystring.stringify(param);
76+
var auth = util.generateAccessToken(uri, body);
77+
rpc.postWithForm(uri, body, auth, onret);
78+
}
79+

qiniu/rs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,12 @@ PutPolicy.prototype.getFlags = function(putPolicy) {
183183
if (this.endUser != null) {
184184
flags['endUser'] = this.endUser;
185185
}
186+
if (this.persistentOps != null) {
187+
flags['persistentOps'] = this.persistentOps;
188+
}
189+
if (this.persistentNotifyUrl != null) {
190+
flags['persistentNotifyUrl'] = this.persistentNotifyUrl;
191+
}
186192
flags['deadline'] = this.expires + Math.floor(Date.now() / 1000);
187193
return flags;
188194
}

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'}, function(err, ret) {
142+
ret.should.have.keys('persistentId');
143+
done();
144+
});
145+
// @endgist
146+
})
147+
});
136148
});

0 commit comments

Comments
 (0)