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