diff --git a/ufile-sample-java/pom.xml b/ufile-sample-java/pom.xml index ee113dc..b7060ea 100644 --- a/ufile-sample-java/pom.xml +++ b/ufile-sample-java/pom.xml @@ -6,7 +6,7 @@ cn.ucloud.ufile ufile-sample-java - 1.0.1 + 1.0.2 @@ -55,8 +55,8 @@ cn.ucloud.ufile ufile-client-java - 2.6.6 + 2.6.7 - \ No newline at end of file + diff --git a/ufile-sample-java/src/main/java/cn/ucloud/ufile/sample/object/RenameObjectSample.java b/ufile-sample-java/src/main/java/cn/ucloud/ufile/sample/object/RenameObjectSample.java deleted file mode 100644 index 3d3a186..0000000 --- a/ufile-sample-java/src/main/java/cn/ucloud/ufile/sample/object/RenameObjectSample.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.ucloud.ufile.sample.object; - -import cn.ucloud.ufile.UfileClient; -import cn.ucloud.ufile.api.ApiError; -import cn.ucloud.ufile.api.object.ObjectConfig; -import cn.ucloud.ufile.bean.UfileErrorBean; -import cn.ucloud.ufile.bean.base.BaseObjectResponseBean; -import cn.ucloud.ufile.exception.UfileClientException; -import cn.ucloud.ufile.exception.UfileServerException; -import cn.ucloud.ufile.http.UfileCallback; -import cn.ucloud.ufile.sample.Constants; -import cn.ucloud.ufile.util.JLog; -import okhttp3.Request; - - -/** - * @author: joshua - * @E-mail: joshua.yin@ucloud.cn - * @date: 2018-12-11 14:32 - */ -public class RenameObjectSample { - private static final String TAG = "RenameObjectSample"; - private static ObjectConfig config = new ObjectConfig("cn-sh2", "ufileos.com"); - - public static void main(String[] args) { - String bucketName = ""; - String keyName = ""; - String newKeyName = ""; - boolean isForceToCover = false; - renameObject(bucketName, keyName, newKeyName, isForceToCover); - } - - public static void renameObject(String bucketName, String keyName, String newKeyName, boolean isForceToCover) { - try { - BaseObjectResponseBean response = UfileClient.object(Constants.OBJECT_AUTHORIZER, config) - .renameObject(bucketName, keyName) - .isRenamedTo(newKeyName) - /** - * 如果已存在同名文件,值为true则覆盖,否则操作失败;请求中若不携带该参数,默认不覆盖 - */ -// .isForcedToCover(isForceToCover) - .execute(); - JLog.D(TAG, String.format("[res] = %s", (response == null ? "null" : response.toString()))); - } catch (UfileClientException e) { - e.printStackTrace(); - } catch (UfileServerException e) { - e.printStackTrace(); - } - } - - public static void renameObjectAsync(String bucketName, String keyName, String newKeyName, boolean isForceToCover) { - UfileClient.object(Constants.OBJECT_AUTHORIZER, config) - .renameObject(bucketName, keyName) - .isRenamedTo(newKeyName) - /** - * 如果已存在同名文件,值为true则覆盖,否则操作失败;请求中若不携带该参数,默认不覆盖 - */ -// .isForcedToCover(isForceToCover) - .executeAsync(new UfileCallback() { - - @Override - public void onResponse(BaseObjectResponseBean response) { - JLog.D(TAG, String.format("[res] = %s", (response == null ? "null" : response.toString()))); - } - - @Override - public void onError(Request request, ApiError error, UfileErrorBean response) { - JLog.D(TAG, String.format("[error] = %s\n[info] = %s", - (error == null ? "null" : error.toString()), - (response == null ? "null" : response.toString()))); - } - }); - } - -} diff --git a/ufile-sample-java/src/main/java/cn/ucloud/ufile/sample/object/UploadHitSample.java b/ufile-sample-java/src/main/java/cn/ucloud/ufile/sample/object/UploadHitSample.java deleted file mode 100644 index ce5cc60..0000000 --- a/ufile-sample-java/src/main/java/cn/ucloud/ufile/sample/object/UploadHitSample.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.ucloud.ufile.sample.object; - -import cn.ucloud.ufile.UfileClient; -import cn.ucloud.ufile.api.ApiError; -import cn.ucloud.ufile.api.object.ObjectConfig; -import cn.ucloud.ufile.bean.base.BaseObjectResponseBean; -import cn.ucloud.ufile.bean.UfileErrorBean; -import cn.ucloud.ufile.exception.UfileClientException; -import cn.ucloud.ufile.exception.UfileServerException; -import cn.ucloud.ufile.http.UfileCallback; -import cn.ucloud.ufile.sample.Constants; -import cn.ucloud.ufile.util.JLog; -import okhttp3.Request; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.InputStream; - -/** - * @author: joshua - * @E-mail: joshua.yin@ucloud.cn - * @date: 2018-12-11 14:32 - */ -public class UploadHitSample { - private static final String TAG = "UploadHitSample"; - private static ObjectConfig config = new ObjectConfig("cn-sh2", "ufileos.com"); - - public static void main(String[] args) { - File file = new File(""); - InputStream is = new ByteArrayInputStream(new byte[]{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}); - String keyName = ""; - String bucketName = ""; - uploadHitFile(file, keyName, bucketName); - } - - public static void uploadHitFile(File file, String nameAs, String toBucket) { - try { - BaseObjectResponseBean response = UfileClient.object(Constants.OBJECT_AUTHORIZER, config) - .uploadHit(file) - .nameAs(nameAs) - .toBucket(toBucket) - .execute(); - JLog.D(TAG, String.format("[res] = %s", (response == null ? "null" : response.toString()))); - } catch (UfileClientException e) { - e.printStackTrace(); - } catch (UfileServerException e) { - e.printStackTrace(); - } - } - - public static void uploadHitFileAsync(File file, String nameAs, String toBucket) { - UfileClient.object(Constants.OBJECT_AUTHORIZER, config) - .uploadHit(file) - .nameAs(nameAs) - .toBucket(toBucket) - .executeAsync(new UfileCallback() { - - @Override - public void onResponse(BaseObjectResponseBean response) { - JLog.D(TAG, String.format("[res] = %s", (response == null ? "null" : response.toString()))); - } - - @Override - public void onError(Request request, ApiError error, UfileErrorBean response) { - JLog.D(TAG, String.format("[error] = %s\n[info] = %s", - (error == null ? "null" : error.toString()), - (response == null ? "null" : response.toString()))); - } - }); - } - - public static void uploadHitStream(InputStream stream, String nameAs, String toBucket) { - try { - BaseObjectResponseBean response = UfileClient.object(Constants.OBJECT_AUTHORIZER, config) - .uploadHit(stream) - .nameAs(nameAs) - .toBucket(toBucket) - .execute(); - JLog.D(TAG, String.format("[res] = %s", (response == null ? "null" : response.toString()))); - } catch (UfileClientException e) { - e.printStackTrace(); - } catch (UfileServerException e) { - e.printStackTrace(); - } - } - - public static void uploadHitStreamAsync(InputStream stream, String nameAs, String toBucket) { - UfileClient.object(Constants.OBJECT_AUTHORIZER, config) - .uploadHit(stream) - .nameAs(nameAs) - .toBucket(toBucket) - .executeAsync(new UfileCallback() { - - @Override - public void onResponse(BaseObjectResponseBean response) { - JLog.D(TAG, String.format("[res] = %s", (response == null ? "null" : response.toString()))); - } - - @Override - public void onError(Request request, ApiError error, UfileErrorBean response) { - JLog.D(TAG, String.format("[error] = %s\n[info] = %s", - (error == null ? "null" : error.toString()), - (response == null ? "null" : response.toString()))); - } - }); - } -} diff --git a/ufile/pom.xml b/ufile/pom.xml index e430a57..13b9f30 100644 --- a/ufile/pom.xml +++ b/ufile/pom.xml @@ -132,7 +132,7 @@ maven-gpg-plugin ${plugin.maven.gpg.version} - true + false @@ -143,6 +143,18 @@ + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + sonatype-nexus-staging + https://oss.sonatype.org/ + true + +