1- ---
1+ ---
22title : ' 快速使用'
33sidebar :
44 nav : java-sdk
@@ -22,17 +22,18 @@ sidebar:
2222
2323- ** [ ufile-client-java ] ( https://github.com/ucloud/ufile-sdk-java/tree/master/ufile/ufile-client-java/apidocs.zip ) **
2424 - ** [ ufile-core ] ( https://github.com/ucloud/ufile-sdk-java/tree/master/ufile/ufile-core/apidocs.zip ) **
25-
25+
2626## 安装
2727- Maven
2828
29- 您可以通过在pom.xml中添加以下依赖项,来配置您的Maven项目
29+ 您可以通过在pom.xml中添加以下依赖项,来配置您的Maven项目。添加依赖后,请执行项目刷新(如 IDEA 中点击 Reload Project)以使依赖生效。
3030
3131 ``` xml
3232 <dependency >
3333 <groupId >cn.ucloud.ufile</groupId >
3434 <artifactId >ufile-client-java</artifactId >
35- <version >latest-release-version</version >
35+ <!-- 当前推荐版本 -->
36+ <version >2.7.4</version >
3637 </dependency >
3738 ```
3839
@@ -51,11 +52,11 @@ sidebar:
5152
5253- 基本说明:
5354 - 所有API均包含同步执行(execute)和异步执行(executeAsync)两种执行方式。
54-
55+
5556 - 同步执行会返回指定的业务结果类,若执行出错则会抛出UfileException为父类的异常;
56-
57+
5758 - 异步执行需要传入UfileCallback<T >的回调接口,执行成功时会回调onResponse,泛型<T >为回调结果(即:同步执行的返回类型),**值得注意的是,若Ufile Server业务错误,也会回调onResponse,请注意结果类中的信息**,若出现异常,则回调onError。
58-
59+
5960 - 如果是上传下载等耗时API,建议使用异步执行(executeAsync),并可以重写UfileCallback中的onProgress回调来进行进度监听
6061
6162## 配置UfileClient
@@ -76,7 +77,7 @@ sidebar:
7677// Bucket相关API的授权器
7778BucketAuthorization BUCKET_AUTHORIZER = new UfileBucketLocalAuthorization(
7879 "Your PublicKey", "Your PrivateKey");
79-
80+
8081UfileClient.bucket(BUCKET_AUTHORIZER)
8182 .APIs // Bucket相关操作API
8283 .execute() or executeAsync(UfileCallback<T >)
@@ -96,7 +97,7 @@ UfileClient.bucket(BUCKET_AUTHORIZER)
9697 e. printStackTrace();
9798 }
9899 ```
99-
100+
100101- 异步
101102
102103 ``` java
@@ -105,12 +106,12 @@ UfileClient.bucket(BUCKET_AUTHORIZER)
105106 .executeAsync(new UfileCallback<BucketResponse > () {
106107 @Override
107108 public void onResponse (BucketResponse response ) {
108-
109+
109110 }
110-
111+
111112 @Override
112113 public void onError (Request request , ApiError error , UfileErrorBean response ) {
113-
114+
114115 }
115116 });
116117 ```
@@ -123,7 +124,7 @@ UfileClient.bucket(BUCKET_AUTHORIZER)
123124// 对象相关API的授权器
124125ObjectAuthorization OBJECT_AUTHORIZER = new UfileObjectLocalAuthorization (
125126 " Your PublicKey" , " Your PrivateKey" );
126-
127+
127128/**
128129 * 您也可以创建远程对象相关API的授权器,远程授权器将签名私钥放于签名服务器上,更为安全
129130 * 远程签名服务端示例代码在 (https://github.com/ucloud/ufile-sdk-auth-server)
@@ -138,7 +139,7 @@ ObjectAuthorization OBJECT_AUTHORIZER = new UfileObjectRemoteAuthorization(
138139// 对象操作需要ObjectConfig来配置您的地区和域名后缀
139140ObjectConfig config = new ObjectConfig (" your bucket region" , " ufileos.com" );
140141
141- /**
142+ /**
142143 * 您也可以使用已登记的自定义域名
143144 * 注意'http://www.your_domain.com'指向的是某个特定的bucket+region+域名后缀,
144145 * eg:http://www.your_domain.com -> www.your_bucket.bucket_region.ufileos.com
@@ -148,7 +149,7 @@ ObjectConfig config = new ObjectConfig("http://www.your_domain.com");
148149/**
149150 * ObjectConfig同时支持从本地文件来导入
150151 * 配置文件内容必须是含有以下参数的json字符串:
151- * {"Region":"","ProxySuffix":""}
152+ * {"Region":"","ProxySuffix":""}
152153 * 或
153154 * {"CustomDomain":""}
154155 */
@@ -169,7 +170,7 @@ UfileClient.object(OBJECT_AUTHORIZER, config)
169170
170171 ``` java
171172 File file = new File (" your file path" );
172-
173+
173174 try {
174175 PutObjectResultBean response = UfileClient . object(Constants . OBJECT_AUTHORIZER , config)
175176 .putObject(file, " mimeType" )
@@ -189,7 +190,7 @@ UfileClient.object(OBJECT_AUTHORIZER, config)
189190 .setOnProgressListener(new OnProgressListener () {
190191 @Override
191192 public void onProgress (long bytesWritten , long contentLength ) {
192-
193+
193194 }
194195 })
195196 .execute();
@@ -204,7 +205,7 @@ UfileClient.object(OBJECT_AUTHORIZER, config)
204205
205206 ``` java
206207 File file = new File (" your file path" );
207-
208+
208209 UfileClient . object(OBJECT_AUTHORIZER , config)
209210 .putObject(file, " mimeType" )
210211 .nameAs(" save as keyName" )
@@ -220,17 +221,17 @@ UfileClient.object(OBJECT_AUTHORIZER, config)
220221 .executeAsync(new UfileCallback<PutObjectResultBean > () {
221222 @Override
222223 public void onProgress (long bytesWritten , long contentLength ) {
223-
224+
224225 }
225-
226+
226227 @Override
227228 public void onResponse (PutObjectResultBean response ) {
228-
229+
229230 }
230-
231+
231232 @Override
232233 public void onError (Request request , ApiError error , UfileErrorBean response ) {
233-
234+
234235 }
235236 });
236237 ```
0 commit comments