Skip to content

Commit 5565147

Browse files
authored
Merge pull request #410 from qiniu/developer
Revert 307 - 404 and Fix bugs
2 parents d9f51cd + 2e6ba31 commit 5565147

File tree

9 files changed

+59
-3
lines changed

9 files changed

+59
-3
lines changed

src/main/java/com/qiniu/common/AutoRegion.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public AutoRegion(String ucServer) {
5555

5656
/**
5757
* 通过 API 接口查询上传域名
58+
* z0: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-z0
59+
* z1: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-z1
60+
* z2: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-z2
61+
* as0: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-as0
62+
* na0: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-na0
5863
*/
5964
private UCRet getRegionJson(RegionIndex index) throws QiniuException {
6065
String address = ucServer + "/v2/query?ak=" + index.accessKey + "&bucket=" + index.bucket;

src/main/java/com/qiniu/processing/OperationManager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public OperationManager(Auth auth, Configuration cfg) {
4949
public OperationManager(Auth auth, Client client) {
5050
this.auth = auth;
5151
this.client = client;
52+
this.configuration = new Configuration();
5253
}
5354

5455
/**
@@ -84,7 +85,11 @@ public String pfop(String bucket, String key, String fops, StringMap params) thr
8485
String url = configuration.apiHost(auth.accessKey, bucket) + "/pfop/";
8586
StringMap headers = auth.authorization(url, data, Client.FormMime);
8687
Response response = client.post(url, data, headers, Client.FormMime);
88+
if (!response.isOK()) {
89+
throw new QiniuException(response);
90+
}
8791
PfopResult status = response.jsonToObject(PfopResult.class);
92+
response.close();
8893
if (status != null) {
8994
return status.persistentId;
9095
}
@@ -167,6 +172,11 @@ public <T> T prefop(String persistentId, Class<T> retClass) throws QiniuExceptio
167172
byte[] data = StringUtils.utf8Bytes(params.formString());
168173
String url = String.format("%s/status/get/prefop", configuration.apiHost());
169174
Response response = this.client.post(url, data, null, Client.FormMime);
170-
return response.jsonToObject(retClass);
175+
if (!response.isOK()) {
176+
throw new QiniuException(response);
177+
}
178+
T object = response.jsonToObject(retClass);
179+
response.close();
180+
return object;
171181
}
172182
}

src/main/java/com/qiniu/storage/BucketManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public BucketManager(Auth auth, Configuration cfg) {
5050
public BucketManager(Auth auth, Client client) {
5151
this.auth = auth;
5252
this.client = client;
53+
this.configuration = new Configuration();
5354
}
5455

5556
/**
@@ -497,7 +498,7 @@ public Response asynFetch(String url, String bucket, String key) throws QiniuExc
497498
*/
498499
public Response asynFetch(String url, String bucket, String key, String md5, String etag,
499500
String callbackurl, String callbackbody, String callbackbodytype,
500-
String callbackhost, String fileType) throws QiniuException {
501+
String callbackhost, int fileType) throws QiniuException {
501502
String requesturl = configuration.apiHost(auth.accessKey, bucket) + "/sisyphus/fetch";
502503
StringMap stringMap = new StringMap().put("url", url).put("bucket", bucket).
503504
putNotNull("key", key).putNotNull("md5", md5).putNotNull("etag", etag).

src/main/java/com/qiniu/storage/UploadManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public UploadManager(Configuration config, Recorder recorder) {
4646
public UploadManager(Client client, Recorder recorder) {
4747
this.client = client;
4848
this.recorder = recorder;
49+
configuration = new Configuration();
4950
}
5051

5152
private static void checkArgs(final String key, byte[] data, File f, String token) {

src/main/java/com/qiniu/storage/model/FileInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,8 @@ public final class FileInfo {
3737
* 文件的状态,0表示启用,1表示禁用
3838
*/
3939
public int status;
40+
/**
41+
* 文件的md5值
42+
*/
43+
public String md5;
4044
}

src/test/java/test/com/qiniu/TestConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public static boolean isTravis() {
4444
}
4545

4646
public static void main(String[] args) {
47+
try {
48+
System.out.println("done");
49+
} catch (Exception e) {
50+
e.printStackTrace();
51+
}
4752
}
4853

4954
}

src/test/java/test/com/qiniu/storage/RecordUploadTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void run() {
122122
assertNotNull(response);
123123
assertTrue(response.isOK());
124124
assertEquals(etag, hash);
125-
doSleep(500);
125+
doSleep(2000);
126126
showRecord("nodata: " + size + " :", recorder, recordKey);
127127
assertNull("文件上传成功,但断点记录文件未清理", recorder.get(recordKey));
128128
} finally {
@@ -172,21 +172,33 @@ public void test600k() throws Throwable {
172172

173173
@Test
174174
public void test4M() throws Throwable {
175+
if (TestConfig.isTravis()) {
176+
return;
177+
}
175178
template(1024 * 4);
176179
}
177180

178181
@Test
179182
public void test4M1K() throws Throwable {
183+
if (TestConfig.isTravis()) {
184+
return;
185+
}
180186
template(1024 * 4 + 1);
181187
}
182188

183189
@Test
184190
public void test8M1k() throws Throwable {
191+
if (TestConfig.isTravis()) {
192+
return;
193+
}
185194
template(1024 * 8 + 1);
186195
}
187196

188197
@Test
189198
public void test25M1k() throws Throwable {
199+
if (TestConfig.isTravis()) {
200+
return;
201+
}
190202
template(1024 * 25 + 1);
191203
}
192204

src/test/java/test/com/qiniu/storage/ResumeUploadTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,25 @@ public void test600k2() throws IOException {
122122

123123
@Test
124124
public void test4M() throws Throwable {
125+
if (TestConfig.isTravis()) {
126+
return;
127+
}
125128
template(1024 * 4, false);
126129
}
127130

128131
@Test
129132
public void test8M1k() throws Throwable {
133+
if (TestConfig.isTravis()) {
134+
return;
135+
}
130136
template(1024 * 8 + 1, false);
131137
}
132138

133139
@Test
134140
public void test8M1k2() throws Throwable {
141+
if (TestConfig.isTravis()) {
142+
return;
143+
}
135144
template(1024 * 8 + 1, true);
136145
}
137146

src/test/java/test/com/qiniu/storage/StreamUploadTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,25 @@ public void test600k2() throws IOException {
119119

120120
@Test
121121
public void test4M() throws Throwable {
122+
if (TestConfig.isTravis()) {
123+
return;
124+
}
122125
template(1024 * 4, false);
123126
}
124127

125128
@Test
126129
public void test8M1k() throws Throwable {
130+
if (TestConfig.isTravis()) {
131+
return;
132+
}
127133
template(1024 * 8 + 1, false);
128134
}
129135

130136
@Test
131137
public void test8M1k2() throws Throwable {
138+
if (TestConfig.isTravis()) {
139+
return;
140+
}
132141
template(1024 * 8 + 1, true);
133142
}
134143

0 commit comments

Comments
 (0)