@@ -28,28 +28,43 @@ JDK 7 及以上
28
28
29
29
### 上传
30
30
``` Java
31
+ // 分片上传 v1
31
32
import com.qiniu.storage.UploadManager ;
32
33
import com.qiniu.util.Auth ;
33
34
import com.qiniu.storage.Configuration ;
34
35
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
+
43
47
// 分片上传 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);
51
63
```
52
64
65
+ 其他使用请参考[ 开发指南] https://developer.qiniu.com/kodo/1239/java
66
+ 详细的示例请参考[ Examples] https://github.com/qiniu/java-sdk/tree/master/examples
67
+
53
68
## 测试
54
69
55
70
``` bash
0 commit comments