|
@@ -18,8 +18,11 @@ import com.ym.mec.thirdparty.storage.StoragePlugin;
|
|
|
@Component
|
|
|
public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean, DisposableBean {
|
|
|
|
|
|
- @Value("${storage.oss.endpoint:oss-cn-beijing.aliyuncs.com}")
|
|
|
- private String endpoint;
|
|
|
+ @Value("${storage.oss.outerEndpoint:oss-cn-beijing.aliyuncs.com}")
|
|
|
+ private String outerEndpoint;
|
|
|
+
|
|
|
+ @Value("${storage.oss.innerEndpoint:oss-cn-beijing-internal.aliyuncs.com}")
|
|
|
+ private String innerEndpoint;
|
|
|
|
|
|
@Value("${storage.oss.accessKeyId:LTAI4Fdhxwfo7FsBDZKK8Wfv}")
|
|
|
private String accessKeyId;
|
|
@@ -56,7 +59,7 @@ public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean,
|
|
|
// 设置是否支持将自定义域名作为Endpoint,默认支持。
|
|
|
conf.setSupportCname(true);
|
|
|
|
|
|
- ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret, conf);
|
|
|
+ ossClient = new OSSClient(innerEndpoint, accessKeyId, accessKeySecret, conf);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -71,7 +74,7 @@ public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean,
|
|
|
|
|
|
ossClient.putObject(bucketName, folderName + "/" + file.getName(), file);
|
|
|
|
|
|
- return "https://" + bucketName + "." + endpoint + "/" + folderName + "/" + file.getName();
|
|
|
+ return "https://" + bucketName + "." + outerEndpoint + "/" + folderName + "/" + file.getName();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -93,8 +96,12 @@ public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void setEndpoint(String endpoint) {
|
|
|
- this.endpoint = endpoint;
|
|
|
+ public void setOuterEndpoint(String outerEndpoint) {
|
|
|
+ this.outerEndpoint = outerEndpoint;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setInnerEndpoint(String innerEndpoint) {
|
|
|
+ this.innerEndpoint = innerEndpoint;
|
|
|
}
|
|
|
|
|
|
public void setAccessKeyId(String accessKeyId) {
|
|
@@ -111,10 +118,11 @@ public class AliyunOssStoragePlugin implements StoragePlugin, InitializingBean,
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
AliyunOssStoragePlugin aliyunOssStorageService = new AliyunOssStoragePlugin();
|
|
|
- aliyunOssStorageService.setAccessKeyId("LTAIwZW9XqrfsZ4r");
|
|
|
- aliyunOssStorageService.setAccessKeySecret("5uDsNZmHMxcnxav8w9byII4zcPpu5G");
|
|
|
- aliyunOssStorageService.setBucketName("yooma-test");
|
|
|
- aliyunOssStorageService.setEndpoint("oss-cn-beijing.aliyuncs.com");
|
|
|
+ aliyunOssStorageService.setAccessKeyId("LTAI4Fdhxwfo7FsBDZKK8Wfv");
|
|
|
+ aliyunOssStorageService.setAccessKeySecret("ERRma4P9VWbD98n93gspnZXmoq7rn5");
|
|
|
+ aliyunOssStorageService.setBucketName("daya-online");
|
|
|
+ aliyunOssStorageService.setOuterEndpoint("oss-cn-beijing.aliyuncs.com");
|
|
|
+ aliyunOssStorageService.setInnerEndpoint("oss-cn-beijing-internal.aliyuncs.com");
|
|
|
aliyunOssStorageService.afterPropertiesSet();
|
|
|
|
|
|
File file = new File("e:/var/2.jpg");
|