Quellcode durchsuchen

OssConsoleClient#getObjectInfo 方法添加 channelId 参数

reghao vor 2 Jahren
Ursprung
Commit
cfe5547932

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

@@ -194,8 +194,8 @@ public class OssConsoleClient {
         return webResult.getData();
     }
 
-    public ObjectInfo getObjectInfo(String objectId) throws Exception {
-        String api = String.format("%s/api/oss/object/info?objectId=%s", endpoint, objectId);
+    public ObjectInfo getObjectInfo(int channelId, String objectId) throws Exception {
+        String api = String.format("%s/api/oss/object/info?channelId=%s&objectId=%s", endpoint, channelId, objectId);
         HttpRequest httpRequest = HttpRequest.newBuilder(new URI(api))
                 .header("authorization", "Bearer " + token)
                 .version(HttpClient.Version.HTTP_1_1)

+ 8 - 8
oss-sdk/src/test/java/OssConsoleClientTest.java

@@ -25,11 +25,11 @@ public class OssConsoleClientTest {
 
     public static void main(String[] args) throws Exception {
         String consoleUrl = "http://ossconsole.reghao.cn";
-        String accessKeyId = "z9mtelCi";
-        String accessKeySecret = "mX7dO8zC8dokThJOC2";
+        String accessKeyId = "mWYMpbrL";
+        String accessKeySecret = "uvuTJKKbRfaSxNPM38";
         OssConsoleClient ossConsoleClient = new OssConsoleClient(consoleUrl, accessKeyId, accessKeySecret);
 
-        int channelId = 108;
+        int channelId = 101;
         ServerInfo serverInfo = ossConsoleClient.getServerInfo(channelId);
         if (serverInfo == null) {
             log.info("获取 server_info 失败");
@@ -38,11 +38,6 @@ public class OssConsoleClientTest {
         String ossUrl = serverInfo.getOssUrl();
         String token = serverInfo.getToken();
 
-        /*int scope = 1;
-        String objectId = "dafafafa";
-        int contentType = 1001;
-        ossConsoleClient.setObjectScope(scope, objectId, contentType);*/
-
         OssStoreClient ossStoreClient = new OssStoreClient(ossUrl);
         String filePath = "/home/reghao/data/video/output.mp4";
         File file = new File(filePath);
@@ -58,5 +53,10 @@ public class OssConsoleClientTest {
 
         /*String sha256sum = "1234567890";
         storeClient.headObject1(sha256sum);*/
+
+        /*int scope = 1;
+        String objectId = "dafafafa";
+        int contentType = 1001;
+        ossConsoleClient.setObjectScope(scope, objectId, contentType);*/
     }
 }