Skip to content

Commit 91ac945

Browse files
authored
Merge pull request #541 from YangSen-qn/master
change README.md example of upload
2 parents d2ac99a + a328f26 commit 91ac945

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

README.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,43 @@ JDK 7 及以上
2828

2929
### 上传
3030
```Java
31+
// 分片上传 v1
3132
import com.qiniu.storage.UploadManager;
3233
import com.qiniu.util.Auth;
3334
import com.qiniu.storage.Configuration;
3435
import com.qiniu.http.Response;
35-
...
36-
// 分片上传 v1
37-
Configuration cfg = new Configuration();
38-
UploadManager uploadManager = new UploadManager(cfg);
39-
Auth auth = Auth.create(accessKey, secretKey);
40-
String token = auth.uploadToken(bucketName);
41-
Response r = upManager.put("hello world".getBytes(), "yourkey", token);
42-
36+
37+
String accessKey = "Your AccessKey";
38+
String secretKey = "Your SecretKey";
39+
String bucketName = "upload to bucket";
40+
Configuration cfg = new Configuration();
41+
UploadManager uploadManager = new UploadManager(cfg);
42+
Auth auth = Auth.create(accessKey, secretKey);
43+
String token = auth.uploadToken(bucketName);
44+
String key = "file save key";
45+
Response r = uploadManager.put("hello world".getBytes(), key, token);
46+
4347
// 分片上传 v2
44-
Configuration cfg = new Configuration();
45-
cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;
46-
UploadManager uploadManager = new UploadManager(cfg);
47-
Auth auth = Auth.create(accessKey, secretKey);
48-
String token = auth.uploadToken(bucketName);
49-
Response r = upManager.put("hello world".getBytes(), "yourkey", token);
50-
...
48+
import com.qiniu.storage.UploadManager;
49+
import com.qiniu.util.Auth;
50+
import com.qiniu.storage.Configuration;
51+
import com.qiniu.http.Response;
52+
53+
String accessKey = "Your AccessKey";
54+
String secretKey = "Your SecretKey";
55+
String bucketName = "upload to bucket";
56+
Configuration cfg = new Configuration();
57+
cfg.resumableUploadAPIVersion = Configuration.ResumableUploadAPIVersion.V2;
58+
UploadManager uploadManager = new UploadManager(cfg);
59+
Auth auth = Auth.create(accessKey, secretKey);
60+
String token = auth.uploadToken(bucketName);
61+
String key = "file save key";
62+
Response r = uploadManager.put("hello world".getBytes(), key, token);
5163
```
5264

65+
其他使用请参考[开发指南]https://developer.qiniu.com/kodo/1239/java
66+
详细的示例请参考[Examples]https://github.com/qiniu/java-sdk/tree/master/examples
67+
5368
## 测试
5469

5570
``` bash

0 commit comments

Comments
 (0)