|
@@ -17,6 +17,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.util.Base64Utils;
|
|
import org.springframework.util.Base64Utils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.*;
|
|
import java.io.*;
|
|
@@ -413,4 +414,23 @@ public class AliyunOssTemplate implements FileStorageTemplate {
|
|
host=this.getBucket()+"."+host;
|
|
host=this.getBucket()+"."+host;
|
|
return new URI(uri.getScheme(), host, uri.getPath()+"/"+key, uri.getFragment()).toString();
|
|
return new URI(uri.getScheme(), host, uri.getPath()+"/"+key, uri.getFragment()).toString();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void copyFolder(String sourcePath, String targetPath) {
|
|
|
|
+ copyFolder(ossProperties.getBucket(), sourcePath, ossProperties.getBucket(), targetPath);
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
|
|
+ public void copyFolder(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
|
|
|
|
+ try {
|
|
|
|
+ List<String> files = this.getFileFolder(sourceBucketName, sourcePath);
|
|
|
|
+ if (ObjectUtils.isEmpty(files)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ files.stream().forEach(file -> {
|
|
|
|
+ this.copyObject(sourceBucketName, file, targetBucketName ,file.replace(sourcePath, targetPath));
|
|
|
|
+ });
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("列举文件目录失败,key:" + sourcePath, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|