Pārlūkot izejas kodu

fss endpoint config

deason 1 gadu atpakaļ
vecāks
revīzija
d1f75187c6

+ 15 - 1
examcloud-support/src/main/java/cn/com/qmth/examcloud/support/fss/FssProperty.java

@@ -15,13 +15,17 @@ public class FssProperty {
 
     public static String FSS_REGION_ID;
 
+    public static String FSS_ENDPOINT;
+
+    public static String FSS_INTERNAL_ENDPOINT;
+
     public static String FSS_ACCESS_KEY_ID;
 
     public static String FSS_ACCESS_KEY_SECRET;
 
     public static String FSS_URL_PREFIX;
 
-    @Value("${examcloud.fss.type}")
+    @Value("${examcloud.fss.type:}")
     public void fssType(FssType fssType) {
         FSS_TYPE = fssType;
     }
@@ -36,6 +40,16 @@ public class FssProperty {
         FSS_REGION_ID = fssRegionId;
     }
 
+    @Value("${examcloud.fss.endpoint:}")
+    public void fssEndpoint(String fssEndpoint) {
+        FSS_ENDPOINT = fssEndpoint;
+    }
+
+    @Value("${examcloud.fss.internalEndpoint:}")
+    public void fssInternalEndpoint(String fssInternalEndpoint) {
+        FSS_INTERNAL_ENDPOINT = fssInternalEndpoint;
+    }
+
     @Value("${examcloud.fss.accessKeyId:}")
     public void fssAccessKeyId(String fssAccessKeyId) {
         FSS_ACCESS_KEY_ID = fssAccessKeyId;

+ 2 - 4
examcloud-support/src/main/java/cn/com/qmth/examcloud/support/fss/impl/AliyunOssService.java

@@ -218,10 +218,8 @@ public class AliyunOssService implements FssService {
         try {
             // ClientBuilderConfiguration configuration = new ClientBuilderConfiguration();
 
-            final String endpoint = "https://" + FssProperty.FSS_REGION_ID + ".aliyuncs.com";
-            final String internalEndpoint = "https://" + FssProperty.FSS_REGION_ID + "-internal.aliyuncs.com";
-
-            OSS client = new OSSClientBuilder().build(this.internal ? internalEndpoint : endpoint,
+            OSS client = new OSSClientBuilder().build(
+                    this.internal ? FssProperty.FSS_INTERNAL_ENDPOINT : FssProperty.FSS_ENDPOINT,
                     FssProperty.FSS_ACCESS_KEY_ID, FssProperty.FSS_ACCESS_KEY_SECRET);
             // client.setBucketTransferAcceleration(FssProperty.FSS_BUCKET, true);
 

+ 4 - 0
examcloud-support/src/test/java/cn/com/qmth/examcloud/support/test/OssClientTest.java

@@ -27,6 +27,8 @@ public class OssClientTest {
         FssProperty.FSS_TYPE = FssType.ALIYUN_OSS;
         FssProperty.FSS_BUCKET = "examcloud-test";
         FssProperty.FSS_REGION_ID = "oss-cn-shenzhen";
+        FssProperty.FSS_ENDPOINT = "https://oss-cn-shenzhen.aliyuncs.com";
+        FssProperty.FSS_INTERNAL_ENDPOINT = "https://oss-cn-shenzhen-internal.aliyuncs.com";
         FssProperty.FSS_ACCESS_KEY_ID = "LTAI4FboXLCJzrjVo5dUoXaU";
         FssProperty.FSS_ACCESS_KEY_SECRET = "xxx";
         // FssProperty.FSS_URL_PREFIX = "https://examcloud-test.oss-cn-shenzhen.aliyuncs.com";
@@ -35,6 +37,8 @@ public class OssClientTest {
         // FssProperty.FSS_TYPE = FssType.TENCENT_COS;
         // FssProperty.FSS_BUCKET = "examcloud-1252178304";
         // FssProperty.FSS_REGION_ID = "ap-guangzhou";
+        // FssProperty.FSS_ENDPOINT = "https://cos.ap-guangzhou.myqcloud.com";
+        // FssProperty.FSS_INTERNAL_ENDPOINT = "https://cos.ap-guangzhou.myqcloud.com";
         // FssProperty.FSS_ACCESS_KEY_ID = "AKID51lO89AEFNRNA90jGZiw9E5kCQh7djpn";
         // FssProperty.FSS_ACCESS_KEY_SECRET = "xxx";
         // FssProperty.FSS_URL_PREFIX = "https://examcloud-1252178304.cos.ap-guangzhou.myqcloud.com";