Bläddra i källkod

更新 oss-sdk

reghao 1 år sedan
förälder
incheckning
050d1e2ccb

+ 77 - 98
oss-sdk/src/main/java/cn/reghao/oss/sdk/ObjectMultipartUploadService.java

@@ -10,7 +10,6 @@ import cn.reghao.jutil.jdk.serializer.JsonConverter;
 import cn.reghao.jutil.tool.http.DefaultWebRequest;
 import cn.reghao.oss.api.rest.UploadFilePart;
 import cn.reghao.oss.api.rest.UploadFileRet;
-import cn.reghao.oss.api.rest.UploadPrepareRet;
 import cn.reghao.oss.api.rest.UploadedPart;
 import com.google.gson.reflect.TypeToken;
 import lombok.extern.slf4j.Slf4j;
@@ -45,28 +44,29 @@ public class ObjectMultipartUploadService {
         this.token = token;
     }
 
-    public UploadPrepareRet create(File file) throws Exception {
-        String filename = file.getName();
-        long len = file.length();
+    /**
+     * 获取已上传的分片文件
+     *
+     * @param
+     * @return
+     * @date 2024-10-29 15:43:46
+     */
+    public UploadedPart getUploadedParts(File file, int channelId) throws Exception {
         String sha256sum = DigestUtil.sha256sum(file.getAbsolutePath());
-
         MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
-        publisher.addPart("filename", filename)
-                .addPart("size", ""+len)
-                .addPart("sha256sum", sha256sum);
+        publisher.addPart("sha256sum", sha256sum);
 
-        String api = endpoint + "/?create";
+        String api = endpoint + "/?multiparts";
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .version(HttpClient.Version.HTTP_1_1)
-                .header("Authorization", "Bearer " + token)
-                .header("Content-Type", "multipart/form-data; boundary=" + publisher.getBoundary())
-                .POST(publisher.build())
+                .header("Authorization", token)
+                .GET()
                 .build();
 
         HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
         String body = httpResponse.body();
-        Type type = new TypeToken<WebResult<UploadPrepareRet>>(){}.getType();
-        WebResult<UploadPrepareRet> webResult = JsonConverter.jsonToObject(body, type);
+        Type type = new TypeToken<WebResult<UploadedPart>>(){}.getType();
+        WebResult<UploadedPart> webResult = JsonConverter.jsonToObject(body, type);
         if (webResult.getCode() != 0) {
             String errMsg = webResult.getMsg();
             return null;
@@ -75,32 +75,73 @@ public class ObjectMultipartUploadService {
         return webResult.getData();
     }
 
-    public UploadedPart get(File file) throws Exception {
-        //String sha256sum = DigestUtil.sha256sum(file.getAbsolutePath());
-        String sha256sum = "";
-        MultiPartBodyPublisher publisher = new MultiPartBodyPublisher();
-        publisher
-                .addPart("sha256sum", sha256sum);
+    /**
+     * 分片上传大文件
+     *
+     * @param
+     * @return
+     * @date 2024-10-29 15:44:13
+     */
+    public UploadFileRet uploadFilePart(File file, int channelId) throws Exception {
+        String identifier = DigestUtil.sha256sum(new FileInputStream(file));
+        String filename = file.getName();
+        String relativePath = file.getAbsolutePath();
 
-        String api = endpoint + "/?get_multipart";
-        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
-                .version(HttpClient.Version.HTTP_1_1)
-                .header("Authorization", token)
-                .header("Content-Type", "multipart/form-data; boundary=" + publisher.getBoundary())
-                .POST(publisher.build())
-                //.GET()
-                .build();
+        long totalSize = file.length();
+        // 分片大小在 10MB - 100MB 之间,只有最后一个分片才允许小于 10MB(这无法避免)
+        long chunkSize = fileSplitter.getPartSize();
+        long totalChunks = totalSize/chunkSize;
+        if (totalSize % chunkSize != 0) {
+            totalChunks += 1;
+        }
 
-        HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
-        String body = httpResponse.body();
-        Type type = new TypeToken<WebResult<UploadedPart>>(){}.getType();
-        WebResult<UploadedPart> webResult = JsonConverter.jsonToObject(body, type);
-        if (webResult.getCode() != 0) {
-            String errMsg = webResult.getMsg();
-            return null;
+        Map<Integer, Long> map = new HashMap<>();
+        List<Integer> failedChunkNumbers = new ArrayList<>();
+        for (int i = 0; i < totalChunks; i++) {
+            long start = i*chunkSize;
+            // 从 start 位置开始读取 chunkSize 的数据
+            byte[] part = fileSplitter.getPart(file.getAbsolutePath(), start);
+            int chunkNumber = i + 1;
+            map.put(chunkNumber, start);
+
+            int currentChunkSize = part.length;
+            UploadFilePart uploadFilePart = new UploadFilePart(channelId, identifier, filename, relativePath,
+                    totalSize, chunkSize, totalChunks, chunkNumber, currentChunkSize);
+
+            UploadFileRet uploadFileRet = postObject(part, uploadFilePart);
+            if (uploadFileRet == null) {
+                log.info("{}:{} upload failed", chunkNumber, currentChunkSize);
+                failedChunkNumbers.add(chunkNumber);
+            } else {
+                log.info("{}:{} uploaded {} bytes", totalChunks, chunkNumber, currentChunkSize);
+                if (uploadFileRet.isMerged()) {
+                    return uploadFileRet;
+                }
+            }
         }
 
-        return webResult.getData();
+        // 重传上传失败的文件分片
+        if (!failedChunkNumbers.isEmpty()) {
+            for (int chunkNumber : failedChunkNumbers) {
+                long start = map.get(chunkNumber);
+                byte[] part = fileSplitter.getPart(file.getAbsolutePath(), start);
+                int currentChunkSize = part.length;
+                UploadFilePart uploadFilePart = new UploadFilePart(channelId, identifier, filename, relativePath,
+                        totalSize, chunkSize, totalChunks, chunkNumber, currentChunkSize);
+
+                UploadFileRet uploadFileRet = postObject(part, uploadFilePart);
+                if (uploadFileRet == null) {
+                    log.info("{}:{} upload failed", chunkNumber, currentChunkSize);
+                } else {
+                    log.info("{}:{} uploaded {} bytes", totalChunks, chunkNumber, currentChunkSize);
+                    if (uploadFileRet.isMerged()) {
+                        return uploadFileRet;
+                    }
+                }
+            }
+        }
+
+        return null;
     }
 
     /**
@@ -173,66 +214,4 @@ public class ObjectMultipartUploadService {
 
         return webResult.getData();
     }
-
-    public UploadFileRet upload(File file, int channelId) throws Exception {
-        String identifier = DigestUtil.sha256sum(new FileInputStream(file));
-        String filename = file.getName();
-        String relativePath = file.getAbsolutePath();
-
-        long totalSize = file.length();
-        // 分片大小在 10MB - 100MB 之间,只有最后一个分片才允许小于 10MB(这无法避免)
-        long chunkSize = fileSplitter.getPartSize();
-        long totalChunks = totalSize/chunkSize;
-        if (totalSize % chunkSize != 0) {
-            totalChunks += 1;
-        }
-
-        Map<Integer, Long> map = new HashMap<>();
-        List<Integer> failedChunkNumbers = new ArrayList<>();
-        for (int i = 0; i < totalChunks; i++) {
-            long start = i*chunkSize;
-            // 从 start 位置开始读取 chunkSize 的数据
-            byte[] part = fileSplitter.getPart(file.getAbsolutePath(), start);
-            int chunkNumber = i + 1;
-            map.put(chunkNumber, start);
-
-            int currentChunkSize = part.length;
-            UploadFilePart uploadFilePart = new UploadFilePart(channelId, identifier, filename, relativePath,
-                    totalSize, chunkSize, totalChunks, chunkNumber, currentChunkSize);
-
-            UploadFileRet uploadFileRet = postObject(part, uploadFilePart);
-            if (uploadFileRet == null) {
-                log.info("{}:{} upload failed", chunkNumber, currentChunkSize);
-                failedChunkNumbers.add(chunkNumber);
-            } else {
-                log.info("{}:{} uploaded {} bytes", totalChunks, chunkNumber, currentChunkSize);
-                if (uploadFileRet.isMerged()) {
-                    return uploadFileRet;
-                }
-            }
-        }
-
-        // 重传上传失败的文件分片
-        if (!failedChunkNumbers.isEmpty()) {
-            for (int chunkNumber : failedChunkNumbers) {
-                long start = map.get(chunkNumber);
-                byte[] part = fileSplitter.getPart(file.getAbsolutePath(), start);
-                int currentChunkSize = part.length;
-                UploadFilePart uploadFilePart = new UploadFilePart(channelId, identifier, filename, relativePath,
-                        totalSize, chunkSize, totalChunks, chunkNumber, currentChunkSize);
-
-                UploadFileRet uploadFileRet = postObject(part, uploadFilePart);
-                if (uploadFileRet == null) {
-                    log.info("{}:{} upload failed", chunkNumber, currentChunkSize);
-                } else {
-                    log.info("{}:{} uploaded {} bytes", totalChunks, chunkNumber, currentChunkSize);
-                    if (uploadFileRet.isMerged()) {
-                        return uploadFileRet;
-                    }
-                }
-            }
-        }
-
-        return null;
-    }
 }

+ 17 - 35
oss-sdk/src/main/java/cn/reghao/oss/sdk/OssConsoleClient.java

@@ -29,13 +29,9 @@ public class OssConsoleClient {
     private final String endpoint;
     private String token;
 
-    public OssConsoleClient(OssConsoleConfig ossProperties) throws Exception {
-        this.endpoint = ossProperties.getConsoleUrl();
-        auth(ossProperties.getAccessKeyId(), ossProperties.getAccessKeySecret());
-    }
-
-    public OssConsoleClient(String endpoint) {
-        this.endpoint = endpoint;
+    public OssConsoleClient(OssConsoleConfig ossConsoleConfig) throws Exception {
+        this.endpoint = ossConsoleConfig.getConsoleUrl();
+        auth(ossConsoleConfig.getAccessKeyId(), ossConsoleConfig.getAccessKeySecret());
     }
 
     // ****************************************************************************************************************
@@ -99,31 +95,6 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public Integer getChannelScope(int channelId) throws Exception {
-        String api = String.format("%s/api/oss/channel/scope?channelId=%s", endpoint, channelId);
-        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
-                .header("authorization", "Bearer " + token)
-                .version(HttpClient.Version.HTTP_1_1)
-                .GET()
-                .build();
-        HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
-        int statusCode = httpResponse.statusCode();
-        String body = httpResponse.body();
-        if (statusCode != 200) {
-            String errMsg = String.format("%s -> %s", statusCode, body);
-            throw new Exception(errMsg);
-        }
-
-        Type type = new TypeToken<WebResult<Integer>>(){}.getType();
-        WebResult<Integer> webResult = JsonConverter.jsonToObject(body, type);
-        if (webResult.getCode() != 0) {
-            String errMsg = String.format("%s - %s", webResult.getCode(), webResult.getMsg());
-            throw new Exception(errMsg);
-        }
-
-        return webResult.getData();
-    }
-
     public void setObjectScope(int channelId, String objectId, int scope) throws Exception {
         Map<String, String> formData = new HashMap<>();
         formData.put("channelId", channelId+"");
@@ -413,7 +384,10 @@ public class OssConsoleClient {
         }
     }
 
-    public UploadFileRet uploadFile(int channelId, File file) throws Exception {
+    // ****************************************************************************************************************
+    // 对象访问接口
+    // ****************************************************************************************************************
+    public UploadFileRet postObject(File file, int channelId) throws Exception {
         ServerInfo serverInfo = getUploadStore(channelId);
         if (serverInfo == null) {
             throw new Exception("获取 server_info 失败");
@@ -426,7 +400,7 @@ public class OssConsoleClient {
         return uploadFileRet;
     }
 
-    public UploadFileRet uploadFilePart(int channelId, File file) throws Exception {
+    public UploadFileRet postObjectByMultiparts(File file, int channelId) throws Exception {
         ServerInfo serverInfo = getUploadStore(channelId);
         if (serverInfo == null) {
             throw new Exception("获取 server_info 失败");
@@ -435,7 +409,15 @@ public class OssConsoleClient {
         String token = serverInfo.getToken();
 
         ObjectMultipartUploadService multipartUploadService = new ObjectMultipartUploadService(ossUrl, token);
-        UploadFileRet uploadFileRet = multipartUploadService.upload(file, channelId);
+        UploadFileRet uploadFileRet = multipartUploadService.uploadFilePart(file, channelId);
         return uploadFileRet;
     }
+
+    public boolean headObject(String objectName) {
+        return false;
+    }
+
+    public String getObject(String objectName) {
+        return null;
+    }
 }

+ 48 - 93
oss-sdk/src/main/java/cn/reghao/oss/sdk/OssStoreClient.java

@@ -11,10 +11,7 @@ import com.google.gson.reflect.TypeToken;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
+import java.io.*;
 import java.lang.reflect.Type;
 import java.net.URI;
 import java.net.http.HttpClient;
@@ -35,7 +32,6 @@ public class OssStoreClient {
     private final String endpoint;
     private final HttpClient httpClient = HttpClient.newBuilder().build();
     private final DefaultWebRequest webRequest = new DefaultWebRequest();
-    private final String baseDir = "/opt/tmp/";
 
     public OssStoreClient(String endpoint) {
         this.endpoint = endpoint;
@@ -70,26 +66,6 @@ public class OssStoreClient {
         return getResult(httpResponse);
     }
 
-    public UploadFileRet postObjectWithJdkHttp(File file, int channelId, String token) throws Exception {
-        String sha256sum = DigestUtil.sha256sum(file.getAbsolutePath());
-        MultiPartBodyPublisher publisher = new MultiPartBodyPublisher()
-                .addPart("file", Paths.get(file.getAbsolutePath()))
-                .addPart("client", "oss-sdk-1.0")
-                .addPart("sha256sum", sha256sum)
-                .addPart("channelId", channelId+"");
-
-        String api = String.format("%s/", endpoint);
-        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
-                .version(HttpClient.Version.HTTP_1_1)
-                .header("authorization", "Bearer " + token)
-                .header("content-type", "multipart/form-data; boundary=" + publisher.getBoundary())
-                .POST(publisher.build())
-                .build();
-
-        HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
-        return getResult(httpResponse);
-    }
-
     public UploadFileRet postObject(File file, int channelId, String token) throws Exception {
         String sha256sum = DigestUtil.sha256sum(file.getAbsolutePath());
         Map<String, String> map = new HashMap<>();
@@ -116,6 +92,26 @@ public class OssStoreClient {
         return webResult.getData();
     }
 
+    public UploadFileRet postObjectWithJdkHttp(File file, int channelId, String token) throws Exception {
+        String sha256sum = DigestUtil.sha256sum(file.getAbsolutePath());
+        MultiPartBodyPublisher publisher = new MultiPartBodyPublisher()
+                .addPart("file", Paths.get(file.getAbsolutePath()))
+                .addPart("client", "oss-sdk-1.0")
+                .addPart("sha256sum", sha256sum)
+                .addPart("channelId", channelId+"");
+
+        String api = String.format("%s/", endpoint);
+        HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
+                .version(HttpClient.Version.HTTP_1_1)
+                .header("authorization", "Bearer " + token)
+                .header("content-type", "multipart/form-data; boundary=" + publisher.getBoundary())
+                .POST(publisher.build())
+                .build();
+
+        HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
+        return getResult(httpResponse);
+    }
+
     private UploadFileRet getResult(HttpResponse<String> httpResponse) throws Exception {
         int statusCode = httpResponse.statusCode();
         String body = httpResponse.body();
@@ -134,7 +130,7 @@ public class OssStoreClient {
         return webResult.getData();
     }
 
-    public void headObject(String objectName) {
+    public boolean headObject(String objectName) {
         try {
             String api = String.format("%s/%s", endpoint, objectName);
             HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
@@ -143,9 +139,17 @@ public class OssStoreClient {
                     .build();
 
             HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
+            int statusCode = httpResponse.statusCode();
+            if (statusCode == 200) {
+                return true;
+            } else if (statusCode == 404) {
+                return false;
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }
+
+        return false;
     }
 
     public boolean headObject1(String sha256sum) {
@@ -170,7 +174,7 @@ public class OssStoreClient {
         return false;
     }
 
-    public void getObject(String objectName, String filePath) {
+    public String getObject(String objectName, String savedDir) {
         try {
             String version = "1.0.0";
             String api = String.format("%s/%s?client=%s", endpoint, objectName, version);
@@ -182,86 +186,37 @@ public class OssStoreClient {
             HttpResponse<InputStream> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofInputStream());
             int statusCode = httpResponse.statusCode();
             if (statusCode == 200) {
-                String localPath = saveFile(filePath, httpResponse.body());
-                log.info("saved to {}", localPath);
+                int idx = objectName.lastIndexOf("/");
+                String filename = objectName.substring(idx+1);
+                String savedPath = String.format("%s/%s", savedDir, filename);
+                saveFile(savedPath, httpResponse.body());
+                return savedPath;
             } else {
                 log.error("{}", statusCode);
             }
         } catch (Exception e) {
             e.printStackTrace();
         }
-    }
-
-    public String saveFile(String filePath, InputStream in) {
-        File file = new File(filePath);
-        File parentDir = file.getParentFile();
-        try {
-            if (!parentDir.exists()) {
-                FileUtils.forceMkdir(parentDir);
-            }
-
-            FileOutputStream fos = new FileOutputStream(file);
-            // 1MB
-            int len = 1024*1024*5;
-            byte[] buf = new byte[len];
-            int readLen;
-            while ((readLen = in.read(buf, 0, len)) != -1) {
-                fos.write(buf, 0, readLen);
-            }
-            fos.close();
-            return filePath;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
 
         return null;
     }
 
-    public void getObject(String objectName) {
-        try {
-            String version = "1.0.0";
-            String api = String.format("%s/%s?client=%s", endpoint, objectName, version);
-            HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
-                    .version(HttpClient.Version.HTTP_1_1)
-                    .GET()
-                    .build();
-
-            HttpResponse<InputStream> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofInputStream());
-            int statusCode = httpResponse.statusCode();
-            if (statusCode == 200) {
-                String localPath = saveFile(httpResponse.body(), objectName);
-                log.info("saved to {}", localPath);
-            } else {
-                log.error("{}", statusCode);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public String saveFile(InputStream in, String objectName) {
-        String filePath = baseDir + objectName;
+    private void saveFile(String filePath, InputStream in) throws IOException {
         File file = new File(filePath);
         File parentDir = file.getParentFile();
-        try {
-            if (!parentDir.exists()) {
-                FileUtils.forceMkdir(parentDir);
-            }
+        if (!parentDir.exists()) {
+            FileUtils.forceMkdir(parentDir);
+        }
 
-            FileOutputStream fos = new FileOutputStream(file);
-            // 1MB
-            int len = 1024*1024*5;
-            byte[] buf = new byte[len];
-            int readLen;
-            while ((readLen = in.read(buf, 0, len)) != -1) {
-                fos.write(buf, 0, readLen);
-            }
-            fos.close();
-            return filePath;
-        } catch (Exception e) {
-            e.printStackTrace();
+        FileOutputStream fos = new FileOutputStream(file);
+        // 5MB
+        int len = 1024*1024*5;
+        byte[] buf = new byte[len];
+        int readLen;
+        while ((readLen = in.read(buf, 0, len)) != -1) {
+            fos.write(buf, 0, readLen);
         }
 
-        return null;
+        fos.close();
     }
 }

+ 10 - 71
oss-sdk/src/test/java/OssConsoleClientTest.java

@@ -1,15 +1,9 @@
-import cn.reghao.oss.api.rest.UploadPrepareRet;
-import cn.reghao.oss.api.rest.UploadedPart;
 import cn.reghao.oss.sdk.model.OssConsoleConfig;
-import cn.reghao.oss.api.dto.ServerInfo;
 import cn.reghao.oss.api.rest.UploadFileRet;
-import cn.reghao.oss.sdk.ObjectMultipartUploadService;
-import cn.reghao.oss.sdk.OssStoreClient;
 import cn.reghao.oss.sdk.OssConsoleClient;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.*;
-import java.util.List;
 
 /**
  * @author reghao
@@ -17,78 +11,23 @@ import java.util.List;
  */
 @Slf4j
 public class OssConsoleClientTest {
-    static void multipartUpload(String endpoint, int channelId, String token) throws Exception {
-        ObjectMultipartUploadService multipartUploadService = new ObjectMultipartUploadService(endpoint, token);
-        String filePath = "";
-        File file = new File(filePath);
-
-        /*UploadPrepareRet uploadPrepareRet = multipartUploadService.create(file);
-        if (uploadPrepareRet == null) {
-            return;
-        }
-
-        if (uploadPrepareRet.isExist()) {
-            return;
-        }
-
-        String uploadId = uploadPrepareRet.getUploadId();
-        long splitSize = uploadPrepareRet.getSplitSize();*/
-
-        UploadedPart uploadedPart = multipartUploadService.get(file);
-        if (uploadedPart != null) {
-            List<Integer> list = uploadedPart.getUploaded();
-        }
-
-        /*UploadFileRet uploadFileRet = multipartUploadService.upload(file, channelId);
-        if (uploadFileRet != null && uploadFileRet.isMerged()) {
-            String uploadId = uploadFileRet.getUploadId();
-            log.info("file uploaded, uploadId -> {}", uploadId);
-        }*/
-    }
-
-    static void upload(String ossUrl, int channelId, String token) throws Exception {
-        OssStoreClient ossStoreClient = new OssStoreClient(ossUrl);
-        String filePath = "/home/reghao/data/video/output.mp4";
-        File file = new File(filePath);
-        UploadFileRet uploadFileRet = ossStoreClient.postObjectWithJdkHttp(file, channelId, token);
-        if (uploadFileRet == null) {
-            log.info("文件上传失败");
-        } else {
-            log.info("{} -> {}", uploadFileRet.getUploadId(), uploadFileRet.getUrl());
-        }
-    }
-
     public static void main(String[] args) throws Exception {
         String consoleUrl = "http://bnt.reghao.cn";
         String accessKeyId = "ESCKn3Cd";
         String accessKeySecret = "OL9SIOLoOqUjhMiQMv";
-        OssConsoleConfig ossProperties = new OssConsoleConfig(consoleUrl, accessKeyId, accessKeySecret);
-        OssConsoleClient ossConsoleClient = new OssConsoleClient(ossProperties);
-
-        int channelId = 114;
-        ServerInfo serverInfo = ossConsoleClient.getUploadStore(channelId);
-        if (serverInfo == null) {
-            log.info("获取 server_info 失败");
-            return;
-        }
-        String ossUrl = serverInfo.getOssUrl();
-        String token = serverInfo.getToken();
+        OssConsoleConfig ossConsoleConfig = new OssConsoleConfig(consoleUrl, accessKeyId, accessKeySecret);
+        OssConsoleClient ossConsoleClient = new OssConsoleClient(ossConsoleConfig);
 
-        multipartUpload(ossUrl, channelId, token);
-
-        /*String filePath = "";
+        String filePath = "";
         File file = new File(filePath);
-        ossConsoleClient.uploadFilePart(channelId, file);*/
-
-        /*String objectName = "video/playback/28d0fd95e224499c9f2cf1d98b4551a5.flv";
-        ossStoreClient.getObject(objectName);*/
+        int channelId = 114;
+        UploadFileRet uploadFileRet = ossConsoleClient.postObject(file, channelId);
+        UploadFileRet uploadFileRet1 = ossConsoleClient.postObjectByMultiparts(file, channelId);
 
-        /*String sha256sum = "1234567890";
-        storeClient.headObject1(sha256sum);*/
+        String objectName = "video/playback/28d0fd95e224499c9f2cf1d98b4551a5.flv";
+        String localPath  = ossConsoleClient.getObject(objectName);
 
-        /*int scope = 1;
-        String objectId = "dafafafa";
-        int contentType = 1001;
-        ossConsoleClient.setObjectScope(scope, objectId, contentType);*/
+        String sha256sum = "1234567890";
+        boolean exist = ossConsoleClient.headObject(sha256sum);
     }
 }