|
@@ -18,29 +18,25 @@ import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
-@ConditionalOnProperty(name = "fyun.type",havingValue = "local")
|
|
|
|
|
|
+@ConditionalOnProperty(name = "fyun.type", havingValue = "local")
|
|
public class LocalFileService extends AbstractFYunFileService {
|
|
public class LocalFileService extends AbstractFYunFileService {
|
|
|
|
|
|
private Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
private Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String uploadFile(String bucket, byte[] data, String remoteFilePath) {
|
|
public String uploadFile(String bucket, byte[] data, String remoteFilePath) {
|
|
- FileUtil.writeBytes(data, getOssPath(bucket,remoteFilePath));
|
|
|
|
|
|
+ FileUtil.writeBytes(data, getOssPath(bucket, remoteFilePath));
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String uploadFile(String bucket, String filePath, String remoteFilePath) {
|
|
public String uploadFile(String bucket, String filePath, String remoteFilePath) {
|
|
- return uploadFile(bucket, filePath, remoteFilePath, true, null);
|
|
|
|
|
|
+ return uploadFile(bucket, filePath, remoteFilePath, null);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
|
|
public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
|
|
- return uploadFile(bucket, filePath, remoteFilePath, true, headers);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private String uploadFile(String bucket, String filePath, String remoteFilePath, Boolean shutdown,Map<String, String> headers) {
|
|
|
|
- FileUtil.copy(filePath, getOssPath(bucket,remoteFilePath),true);
|
|
|
|
|
|
+ FileUtil.copy(filePath, getOssPath(bucket, remoteFilePath), true);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -73,19 +69,19 @@ public class LocalFileService extends AbstractFYunFileService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void deleteFile(String bucket, String remoteFilePath) throws IOException {
|
|
public void deleteFile(String bucket, String remoteFilePath) throws IOException {
|
|
- FileUtil.del(getOssPath(bucket,remoteFilePath));
|
|
|
|
|
|
+ FileUtil.del(getOssPath(bucket, remoteFilePath));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void deleteFolder(String bucket, String remoteFolderPath) {
|
|
public void deleteFolder(String bucket, String remoteFolderPath) {
|
|
- FileUtil.del(getOssPath(bucket,remoteFolderPath));
|
|
|
|
|
|
+ FileUtil.del(getOssPath(bucket, remoteFolderPath));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void uploadMulFiles(String bucket, Map<String, String> filepaths) {
|
|
public void uploadMulFiles(String bucket, Map<String, String> filepaths) {
|
|
try {
|
|
try {
|
|
for (Map.Entry<String, String> entry : filepaths.entrySet()) {
|
|
for (Map.Entry<String, String> entry : filepaths.entrySet()) {
|
|
- uploadFile(bucket, entry.getKey(), entry.getValue(), false,null);
|
|
|
|
|
|
+ uploadFile(bucket, entry.getKey(), entry.getValue(), null);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("OSS批量上传文件失败!");
|
|
log.error("OSS批量上传文件失败!");
|
|
@@ -99,8 +95,8 @@ public class LocalFileService extends AbstractFYunFileService {
|
|
}
|
|
}
|
|
|
|
|
|
private List<String> listRemoteFiles(String bucket, String sourcePath, Boolean shutdown) {
|
|
private List<String> listRemoteFiles(String bucket, String sourcePath, Boolean shutdown) {
|
|
- return FileUtil.loopFiles(getOssPath(bucket,sourcePath)).stream()
|
|
|
|
- .map(f->f.getAbsolutePath().replace(LocalConstants.BASE_PATH.concat(bucket).concat(File.separator),""))
|
|
|
|
|
|
+ return FileUtil.loopFiles(getOssPath(bucket, sourcePath)).stream()
|
|
|
|
+ .map(f -> f.getAbsolutePath().replace(LocalConstants.BASE_PATH.concat(bucket).concat(File.separator), ""))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
|
|
@@ -129,12 +125,12 @@ public class LocalFileService extends AbstractFYunFileService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String getFileContent(String bucketName, String remoteFilePath) {
|
|
public String getFileContent(String bucketName, String remoteFilePath) {
|
|
- return FileUtil.readUtf8String(getOssPath(bucketName,remoteFilePath));
|
|
|
|
|
|
+ return FileUtil.readUtf8String(getOssPath(bucketName, remoteFilePath));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean fileExist(String bucket, String objectName) {
|
|
public boolean fileExist(String bucket, String objectName) {
|
|
- return FileUtil.exist(getOssPath(bucket,objectName));
|
|
|
|
|
|
+ return FileUtil.exist(getOssPath(bucket, objectName));
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|