|
@@ -25,6 +25,8 @@ public class OssStore implements FileStore {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(OssStore.class);
|
|
private static final Logger log = LoggerFactory.getLogger(OssStore.class);
|
|
|
|
|
|
|
|
+ private static final String ENDPOINT_PREFIX = "https://";
|
|
|
|
+
|
|
private static final Pattern CONFIG_PATTERN = Pattern.compile("^oss://([\\w]+):([\\w]+)@([\\w-]+).([\\w-.]+)$");
|
|
private static final Pattern CONFIG_PATTERN = Pattern.compile("^oss://([\\w]+):([\\w]+)@([\\w-]+).([\\w-.]+)$");
|
|
|
|
|
|
private String endpoint;
|
|
private String endpoint;
|
|
@@ -36,7 +38,7 @@ public class OssStore implements FileStore {
|
|
private String accessSecret;
|
|
private String accessSecret;
|
|
|
|
|
|
public OssStore(String config) {
|
|
public OssStore(String config) {
|
|
- String message = "[file.store]" + config + " pattern error";
|
|
|
|
|
|
+ String message = "[file.store]" + config + ": pattern error";
|
|
Matcher m = CONFIG_PATTERN.matcher(config);
|
|
Matcher m = CONFIG_PATTERN.matcher(config);
|
|
if (m.find()) {
|
|
if (m.find()) {
|
|
accessKey = StringUtils.trimToNull(m.group(1));
|
|
accessKey = StringUtils.trimToNull(m.group(1));
|
|
@@ -49,7 +51,7 @@ public class OssStore implements FileStore {
|
|
Assert.notNull(bucket, message);
|
|
Assert.notNull(bucket, message);
|
|
Assert.notNull(endpoint, message);
|
|
Assert.notNull(endpoint, message);
|
|
|
|
|
|
- endpoint = "https://" + endpoint;
|
|
|
|
|
|
+ endpoint = ENDPOINT_PREFIX.concat(endpoint);
|
|
} else {
|
|
} else {
|
|
throw new IllegalArgumentException(message);
|
|
throw new IllegalArgumentException(message);
|
|
}
|
|
}
|
|
@@ -80,6 +82,7 @@ public class OssStore implements FileStore {
|
|
try {
|
|
try {
|
|
return ossClient.doesObjectExist(bucket, path);
|
|
return ossClient.doesObjectExist(bucket, path);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
+ log.error("oss exist operate error", e);
|
|
return false;
|
|
return false;
|
|
} finally {
|
|
} finally {
|
|
ossClient.shutdown();
|
|
ossClient.shutdown();
|