Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/com/qiniu/common/AutoRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public AutoRegion(String ucServer) {

/**
* 通过 API 接口查询上传域名
* z0: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-z0
* z1: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-z1
* z2: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-z2
* as0: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-as0
* na0: http://uc.qbox.me/v2/query?ak=vHg2e7nOh7Jsucv2Azr5FH6omPgX22zoJRWa0FN5&bucket=sdk-na0
*/
private UCRet getRegionJson(RegionIndex index) throws QiniuException {
String address = ucServer + "/v2/query?ak=" + index.accessKey + "&bucket=" + index.bucket;
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/qiniu/processing/OperationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public OperationManager(Auth auth, Configuration cfg) {
public OperationManager(Auth auth, Client client) {
this.auth = auth;
this.client = client;
this.configuration = new Configuration();
}

/**
Expand Down Expand Up @@ -84,7 +85,11 @@ public String pfop(String bucket, String key, String fops, StringMap params) thr
String url = configuration.apiHost(auth.accessKey, bucket) + "/pfop/";
StringMap headers = auth.authorization(url, data, Client.FormMime);
Response response = client.post(url, data, headers, Client.FormMime);
if (!response.isOK()) {
throw new QiniuException(response);
}
PfopResult status = response.jsonToObject(PfopResult.class);
response.close();
if (status != null) {
return status.persistentId;
}
Expand Down Expand Up @@ -167,6 +172,11 @@ public <T> T prefop(String persistentId, Class<T> retClass) throws QiniuExceptio
byte[] data = StringUtils.utf8Bytes(params.formString());
String url = String.format("%s/status/get/prefop", configuration.apiHost());
Response response = this.client.post(url, data, null, Client.FormMime);
return response.jsonToObject(retClass);
if (!response.isOK()) {
throw new QiniuException(response);
}
T object = response.jsonToObject(retClass);
response.close();
return object;
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/qiniu/storage/BucketManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public BucketManager(Auth auth, Configuration cfg) {
public BucketManager(Auth auth, Client client) {
this.auth = auth;
this.client = client;
this.configuration = new Configuration();
}

/**
Expand Down Expand Up @@ -497,7 +498,7 @@ public Response asynFetch(String url, String bucket, String key) throws QiniuExc
*/
public Response asynFetch(String url, String bucket, String key, String md5, String etag,
String callbackurl, String callbackbody, String callbackbodytype,
String callbackhost, String fileType) throws QiniuException {
String callbackhost, int fileType) throws QiniuException {
String requesturl = configuration.apiHost(auth.accessKey, bucket) + "/sisyphus/fetch";
StringMap stringMap = new StringMap().put("url", url).put("bucket", bucket).
putNotNull("key", key).putNotNull("md5", md5).putNotNull("etag", etag).
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/qiniu/storage/UploadManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public UploadManager(Configuration config, Recorder recorder) {
public UploadManager(Client client, Recorder recorder) {
this.client = client;
this.recorder = recorder;
configuration = new Configuration();
}

private static void checkArgs(final String key, byte[] data, File f, String token) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/qiniu/storage/model/FileInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public final class FileInfo {
* 文件的状态,0表示启用,1表示禁用
*/
public int status;
/**
* 文件的md5值
*/
public String md5;
}
5 changes: 5 additions & 0 deletions src/test/java/test/com/qiniu/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public static boolean isTravis() {
}

public static void main(String[] args) {
try {
System.out.println("done");
} catch (Exception e) {
e.printStackTrace();
}
}

}
14 changes: 13 additions & 1 deletion src/test/java/test/com/qiniu/storage/RecordUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void run() {
assertNotNull(response);
assertTrue(response.isOK());
assertEquals(etag, hash);
doSleep(500);
doSleep(2000);
showRecord("nodata: " + size + " :", recorder, recordKey);
assertNull("文件上传成功,但断点记录文件未清理", recorder.get(recordKey));
} finally {
Expand Down Expand Up @@ -172,21 +172,33 @@ public void test600k() throws Throwable {

@Test
public void test4M() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 4);
}

@Test
public void test4M1K() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 4 + 1);
}

@Test
public void test8M1k() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 8 + 1);
}

@Test
public void test25M1k() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 25 + 1);
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/test/com/qiniu/storage/ResumeUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,25 @@ public void test600k2() throws IOException {

@Test
public void test4M() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 4, false);
}

@Test
public void test8M1k() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 8 + 1, false);
}

@Test
public void test8M1k2() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 8 + 1, true);
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/test/com/qiniu/storage/StreamUploadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,25 @@ public void test600k2() throws IOException {

@Test
public void test4M() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 4, false);
}

@Test
public void test8M1k() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 8 + 1, false);
}

@Test
public void test8M1k2() throws Throwable {
if (TestConfig.isTravis()) {
return;
}
template(1024 * 8 + 1, true);
}

Expand Down