Skip to content

Commit

Permalink
add resume upload
Browse files Browse the repository at this point in the history
  • Loading branch information
yemingm committed Sep 30, 2016
1 parent 4dbd4f0 commit 6de5609
Show file tree
Hide file tree
Showing 13 changed files with 631 additions and 4 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* [获取使用量信息](#获取使用量信息)
* [下载文件](#下载文件)
* [删除文件](#删除文件)
* [断点续传](#断点续传)
* [图片处理接口](#图片处理接口)
* [制作图片缩略图](#制作图片缩略图)
* [图片裁剪](#图片裁剪)
Expand Down Expand Up @@ -360,6 +361,36 @@ public Map<String, String> getFileInfo(String filePath);
boolean result = upyun.deleteFile(filePath);
```

<a name="断点续传"></a>
### 断点续传
初始化 UpResume
```java
UpResume resume = new UpResume("空间名称", "操作员名称", "操作员密码")
```
设置上传进度监听
```java
resume.setOnProgressListener(new UpResume.OnProgressListener()
```
设置 MD5 校验

```java
resume.setCheckMD5(true);
```
开始上传

```java
public boolean upload(String filePath, String uploadPath,Map<String, String> params)
```

**参数说明:**

* `filePath ` 待上传文件路径
* `uploadPath ` 上传至空间目录
* `params ` 通用可选上传参数见文档 可为null

**详细示例:**
见 [ResumeUploadDemo](https://github.com/upyun/java-sdk/blob/master/src/main/java/demo/ResumeUploadDemo)

<a name="图片处理接口"></a>
## 图片处理接口

Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@
<version>20160212
</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/UpYun.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package main.java.com;

import main.java.com.upyun.UpYunUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -888,6 +890,7 @@ private String HttpAction(String method, String uri, byte[] datas,

// 设置时间
conn.setRequestProperty(DATE, getGMTDate());
conn.setRequestProperty("User-Agent", UpYunUtils.VERSION);

// 是否自动创建父级目录
if (auto) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/upyun/AsyncProcessHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected Result process(Map<String, Object> params) throws IOException {
conn.setUseCaches(false);
conn.setDoOutput(true);
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("User-Agent", "upyun-java-sdk/3.8");
conn.setRequestProperty("User-Agent", UpYunUtils.VERSION);

// 设置时间
conn.setRequestProperty(DATE, getGMTDate());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/upyun/FormUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private Result postData(File file, byte[] datas, URL url, String policy, String
conn.setUseCaches(false);
conn.setDoOutput(true);
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("User-Agent", "upyun-java-sdk/3.8");
conn.setRequestProperty("User-Agent", UpYunUtils.VERSION);
conn.setRequestProperty("x-upyun-api-version ", "2");
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
conn.setChunkedStreamingMode(0);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/upyun/MediaHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public Result getResult(Map<String, Object> params) throws IOException {
conn.setUseCaches(false);
conn.setDoOutput(true);
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("User-Agent", "upyun-java-sdk/3.8");
conn.setRequestProperty("User-Agent", UpYunUtils.VERSION);

// 设置时间
conn.setRequestProperty(DATE, getGMTDate());
Expand Down
Loading

0 comments on commit 6de5609

Please sign in to comment.