|
@@ -10,6 +10,7 @@ import com.fdkankan.filestorage.properties.CosProperties;
|
|
|
import com.qcloud.cos.COSClient;
|
|
|
import com.qcloud.cos.model.*;
|
|
|
import lombok.Getter;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -17,6 +18,7 @@ import org.springframework.util.Base64Utils;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.*;
|
|
|
+import java.net.URI;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -403,13 +405,21 @@ public class CosTemplate implements FileStorageTemplate {
|
|
|
public Long getSpace(String key) {
|
|
|
return getSpace(cosProperties.getBucket(), key);
|
|
|
}
|
|
|
+ @SneakyThrows
|
|
|
@Override
|
|
|
- public String getInternalEndpoint(String key) {
|
|
|
- return cosProperties.getInternalEndpoint()+"/"+key;
|
|
|
+ public String getInternalEndpoint(String bucket ,String key) {
|
|
|
+ URI uri = new URI(cosProperties.getInternalEndpoint());
|
|
|
+ String host = uri.getHost();
|
|
|
+ host=bucket+"."+host;
|
|
|
+ return new URI(uri.getScheme(), host, uri.getPath()+"/"+key, uri.getFragment()).toString();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getInternalEndpoint() {
|
|
|
- return cosProperties.getInternalEndpoint()+"/";
|
|
|
+ @SneakyThrows
|
|
|
+ public String getInternalEndpoint(String key) {
|
|
|
+ URI uri = new URI(cosProperties.getInternalEndpoint());
|
|
|
+ String host = uri.getHost();
|
|
|
+ host=this.getBucket()+"."+host;
|
|
|
+ return new URI(uri.getScheme(), host, uri.getPath()+"/"+key, uri.getFragment()).toString();
|
|
|
}
|
|
|
}
|