Skip to content

Commit 74f999f

Browse files
committed
Merge branch 'develop' of github.com:qiniu/java-sdk into update/local-error-code
2 parents 19f9e7e + 4508678 commit 74f999f

File tree

11 files changed

+118
-255
lines changed

11 files changed

+118
-255
lines changed

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
language: java
22

33
before_script:
4-
- export QINIU_ACCESS_KEY=iN7NgwM31j4-BZacMjPrOQBs34UG1maYCAQmhdCV
5-
- export QINIU_SECRET_KEY=6QTOr2Jg1gcZEWDQXKOGZh5PziC2MCV5KsntT70j
4+
- export QINIU_ACCESS_KEY=QWYn5TFQsLLU1pL5MFEmX3s5DmHdUThav9WyOWOm
5+
- export QINIU_SECRET_KEY=Bxckh6FA-Fbs9Yt3i3cbKVK22UPBmAOHJcL95pGz
66
- export QINIU_UP_HOST=http://up.qbox.me
77
- export QINIU_RS_HOST=http://rs.qbox.me
88
- export QINIU_IO_HOST=http://iovip.qbox.me
9-
- export QINIU_TEST_BUCKET=junit_bucket
9+
- export QINIU_TEST_BUCKET=javasdk
10+
- export QINIU_TEST_SRC_BUCKET=testsrc
11+
- export QINIU_TEST_DOMAIN=javasdk.qiniudn.com

src/main/java/com/qiniu/api/rs/PutPolicy.java

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,38 +41,23 @@ public class PutPolicy {
4141
public int detectMime;
4242
/** 可选 */
4343
public long fsizeLimit;
44-
/**限定用户上传的文件类型
44+
/**限定用户上传的文件类型
4545
* 可选
4646
* */
4747
public String mimeLimit;
4848
/** 可选 */
4949
public String persistentNotifyUrl;
5050
/** 可选 */
5151
public String persistentOps;
52-
53-
private long deadline;
5452

55-
/**
56-
*
57-
* 对文件先进行一次变换操作(比如将音频统一转为某种码率的mp3)再进行存储。
58-
* transform的值就是一个fop指令,比如 "avthumb/mp3"。其含义是对上传的文件
59-
* 执行这个 fop 指令,然后把结果保存到七牛。最后保存的是经过处理过的文件,
60-
* 而不是用户上传的原始文件。
61-
*
62-
**/
63-
public String transform;
53+
private long deadline;
54+
55+
/**
56+
* 转码队列名,须预先开通
57+
* 资源上传成功后,触发转码时指定独立的队列进行转码
58+
*/
59+
public String persistentPipeline;
6460

65-
/**
66-
*
67-
* 单位: 秒
68-
* 文件变换操作执行的超时时间(单位:秒),上传和转码操作是同步进行的,
69-
* 先上传后转码,这个时间只是转码所需时间,不包括上传文件所需时间。
70-
* 这个值太小可能会导致误判(最终存储成功了但客户端得到超时的错误),
71-
* 但太大可能会导致服务端将其判断为低优先级任务。建议取一个相对准确的
72-
* 时间估计值*N(N不要超过5)。
73-
*
74-
**/
75-
public long fopTimeout;
7661

7762
public PutPolicy(String scope) {
7863
this.scope = scope;
@@ -121,27 +106,25 @@ public String marshal() throws JSONException {
121106
if (this.persistentOps != null && this.persistentOps.length() > 0) {
122107
stringer.key("persistentOps").value(this.persistentOps);
123108
}
124-
if (this.transform != null && this.transform.length() > 0) {
125-
stringer.key("transform").value(this.transform);
126-
}
127-
if (this.fopTimeout > 0) {
128-
stringer.key("fopTimeout").value(this.fopTimeout);
109+
if(persistentPipeline != null && persistentPipeline.trim().length() > 0){
110+
stringer.key("persistentPipeline").value(this.persistentPipeline);
129111
}
112+
130113
stringer.key("deadline").value(this.deadline);
131114
stringer.endObject();
132115

133116
return stringer.toString();
134117
}
135118

136-
119+
137120
/**
138121
* makes an upload token.
139122
* @param mac
140123
* @return
141124
* @throws AuthException
142125
* @throws JSONException
143126
*/
144-
127+
145128
public String token(Mac mac) throws AuthException, JSONException {
146129
if (this.expires == 0) {
147130
this.expires = 3600; // 3600s, default.

src/test/java/com/qiniu/testing/BatchCopyTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ public class BatchCopyTest extends TestCase {
2626
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";
2727

2828
public String bucketName;
29-
public final String key1 = "BatchCopyTest-key1";
30-
public final String key2 = "BatchCopyTest-key2";
29+
public final String key1 = "java-BatchCopyTest-key1";
30+
public final String key2 = "java-BatchCopyTest-key2";
31+
32+
public final String srcBucket = System.getenv("QINIU_TEST_SRC_BUCKET");
33+
public final String destBucket = System.getenv("QINIU_TEST_BUCKET");
3134

32-
public final String srcBucket = "junit_bucket_src";
33-
public final String destBucket = "junit_bucket_dest";
3435
public Mac mac;
35-
36+
3637
@Override
3738
public void setUp() throws Exception {
3839
// get the config
3940
{
4041
Config.ACCESS_KEY = System.getenv("QINIU_ACCESS_KEY");
4142
Config.SECRET_KEY = System.getenv("QINIU_SECRET_KEY");
4243
Config.RS_HOST = System.getenv("QINIU_RS_HOST");
43-
bucketName = System.getenv("QINIU_TEST_BUCKET");
4444
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
4545
}
4646

@@ -49,7 +49,6 @@ public void setUp() throws Exception {
4949
assertNotNull(Config.ACCESS_KEY);
5050
assertNotNull(Config.SECRET_KEY);
5151
assertNotNull(Config.RS_HOST);
52-
assertNotNull(bucketName);
5352
}
5453

5554
// upload a file to src bucket with key1, key2
@@ -63,8 +62,9 @@ public void setUp() throws Exception {
6362
String localFile = dir + "/testdata/" + "logo.png";
6463

6564
PutExtra extra = new PutExtra();
66-
65+
6766
PutRet ret = IoApi.putFile(uptoken, key1, localFile, extra);
67+
6868
assertTrue(ret.ok());
6969
assertTrue(expectedHash.equals(ret.getHash()));
7070

@@ -173,7 +173,7 @@ public void testBatchCopy() throws Exception {
173173
}
174174
// the dest bucket should have the keys
175175
{
176-
176+
177177
RSClient rs = new RSClient(mac);
178178

179179
List<EntryPath> entries = new ArrayList<EntryPath>();
@@ -228,7 +228,7 @@ public void tearDown() {
228228

229229
// delete keys from the dest bucket
230230
{
231-
231+
232232
RSClient rs = new RSClient(mac);
233233
List<EntryPath> entries = new ArrayList<EntryPath>();
234234

@@ -250,10 +250,10 @@ public void tearDown() {
250250
assertTrue(r.ok());
251251
}
252252
}
253-
253+
254254
// use batchStat to check src bucket
255255
{
256-
256+
257257
RSClient rs = new RSClient(mac);
258258
List<EntryPath> entries = new ArrayList<EntryPath>();
259259

@@ -271,7 +271,7 @@ public void tearDown() {
271271
// check batchCall
272272
assertTrue(!bsRet.ok());
273273
}
274-
274+
275275
// use batchstat checks dest bucket again.
276276
{
277277
RSClient rs = new RSClient(mac);

src/test/java/com/qiniu/testing/BatchMoveTest.java

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,21 @@ public class BatchMoveTest extends TestCase {
2626
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";
2727

2828
public String bucketName;
29-
public final String key1 = "BatchMoveTest-key1";
30-
public final String key2 = "BatchMoveTest-key2";
31-
32-
public final String srcBucket = "junit_bucket_src";
33-
public final String destBucket = "junit_bucket_dest";
29+
public final String key1 = "java-BatchMoveTest-key1";
30+
public final String key2 = "java-BatchMoveTest-key2";
31+
32+
public final String srcBucket = System.getenv("QINIU_TEST_SRC_BUCKET");
33+
public final String destBucket = System.getenv("QINIU_TEST_BUCKET");
3434

3535
public Mac mac;
36-
36+
3737
@Override
3838
public void setUp() throws Exception {
3939
// get the config
4040
{
4141
Config.ACCESS_KEY = System.getenv("QINIU_ACCESS_KEY");
4242
Config.SECRET_KEY = System.getenv("QINIU_SECRET_KEY");
4343
Config.RS_HOST = System.getenv("QINIU_RS_HOST");
44-
bucketName = System.getenv("QINIU_TEST_BUCKET");
4544
mac = new Mac(Config.ACCESS_KEY, Config.SECRET_KEY);
4645
}
4746

@@ -50,7 +49,6 @@ public void setUp() throws Exception {
5049
assertNotNull(Config.ACCESS_KEY);
5150
assertNotNull(Config.SECRET_KEY);
5251
assertNotNull(Config.RS_HOST);
53-
assertNotNull(bucketName);
5452
}
5553

5654
// upload a file to the bucket with key1, key2
@@ -107,41 +105,41 @@ public void testBatchMove() throws Exception {
107105
{
108106
RSClient rs = new RSClient(mac);
109107
List<EntryPathPair> entries = new ArrayList<EntryPathPair>();
110-
108+
111109
EntryPathPair pair1 = new EntryPathPair();
112-
110+
113111
EntryPath src = new EntryPath();
114112
src.bucket = srcBucket;
115113
src.key = key1;
116-
114+
117115
EntryPath dest = new EntryPath();
118116
dest.bucket = destBucket;
119117
dest.key = key1;
120-
118+
121119
pair1.src = src;
122120
pair1.dest = dest;
123-
121+
124122
EntryPathPair pair2 = new EntryPathPair();
125-
123+
126124
EntryPath src2 = new EntryPath();
127125
src2.bucket = srcBucket;
128126
src2.key = key2;
129-
127+
130128
EntryPath dest2 = new EntryPath();
131129
dest2.bucket = destBucket;
132130
dest2.key = key2;
133-
131+
134132
pair2.src = src2;
135133
pair2.dest = dest2;
136-
134+
137135
entries.add(pair1);
138136
entries.add(pair2);
139-
137+
140138
BatchCallRet ret = rs.batchMove(entries);
141-
139+
142140
// check batchMove
143141
assertTrue(ret.ok());
144-
142+
145143
List<CallRet> results = ret.results;
146144
for (CallRet r : results) {
147145
assertTrue(r.ok());
@@ -150,41 +148,41 @@ public void testBatchMove() throws Exception {
150148
// the src keys should not be available in src bucket
151149
{
152150
RSClient rs = new RSClient(mac);
153-
151+
154152
List<EntryPath> entries = new ArrayList<EntryPath>();
155153
EntryPath e1 = new EntryPath();
156154
e1.bucket = srcBucket;
157155
e1.key = key1;
158-
156+
159157
EntryPath e2 = new EntryPath();
160158
e2.bucket = srcBucket;
161159
e2.key = key2;
162-
160+
163161
entries.add(e1);
164162
entries.add(e2);
165-
163+
166164
BatchStatRet ret = rs.batchStat(entries);
167165
assertTrue(!ret.ok());
168166
}
169167
// the dest bucket should have the keys
170168
{
171169
RSClient rs = new RSClient(mac);
172-
170+
173171
List<EntryPath> entries = new ArrayList<EntryPath>();
174172
EntryPath e1 = new EntryPath();
175173
e1.bucket = destBucket;
176174
e1.key = key1;
177-
175+
178176
EntryPath e2 = new EntryPath();
179177
e2.bucket = destBucket;
180178
e2.key = key2;
181-
179+
182180
entries.add(e1);
183181
entries.add(e2);
184-
182+
185183
BatchStatRet ret = rs.batchStat(entries);
186184
assertTrue(ret.ok());
187-
185+
188186
List<Entry> results = ret.results;
189187
for (Entry r : results) {
190188
assertTrue(r.ok());
@@ -221,7 +219,7 @@ public void tearDown() {
221219

222220
// use batchstat checks it again.
223221
{
224-
222+
225223
RSClient rs = new RSClient(mac);
226224
List<EntryPath> entries = new ArrayList<EntryPath>();
227225

src/test/java/com/qiniu/testing/BatchStatTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public class BatchStatTest extends TestCase {
2525
public final String expectedHash = "FmDZwqadA4-ib_15hYfQpb7UXUYR";
2626

2727
public String bucketName;
28-
public final String key1 = "BatchStatTest-key1";
29-
public final String key2 = "BatchStatTest-key2";
28+
public final String key1 = "java-BatchStatTest-key1";
29+
public final String key2 = "java-BatchStatTest-key2";
3030
public Mac mac;
31-
31+
3232
@Override
3333
public void setUp() throws Exception {
3434
// get the config
@@ -59,7 +59,7 @@ public void setUp() throws Exception {
5959
String localFile = dir + "/testdata/" + "logo.png";
6060

6161
PutExtra extra = new PutExtra();
62-
62+
6363
PutRet ret = IoApi.putFile(uptoken, key1, localFile, extra);
6464
assertTrue(ret.ok());
6565
assertTrue(expectedHash.equals(ret.getHash()));

0 commit comments

Comments
 (0)