浏览代码

Merge remote-tracking branch 'origin/feature-v4-20220801' into feature-v4-20220801

dengsixing 2 年之前
父节点
当前提交
781a61a7d8

+ 5 - 0
4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java

@@ -240,6 +240,11 @@ public class OssFileService extends AbstractFYunFileService {
             if (!localFile.getParentFile().exists()) {
             if (!localFile.getParentFile().exists()) {
                 localFile.getParentFile().mkdirs();
                 localFile.getParentFile().mkdirs();
             }
             }
+            if(localFile.isDirectory()){
+                String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
+                log.info("未配置文件名,使用默认文件名:{}",fileName);
+                localPath = localPath.concat(File.separator).concat(fileName);
+            }
             DownloadFileRequest request = new DownloadFileRequest(bucket, remoteFilePath);
             DownloadFileRequest request = new DownloadFileRequest(bucket, remoteFilePath);
             request.setDownloadFile(localPath);
             request.setDownloadFile(localPath);
             // 默认5个任务并发下载
             // 默认5个任务并发下载

+ 5 - 0
4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java

@@ -266,6 +266,11 @@ public class S3FileService extends AbstractFYunFileService {
             if (!localFile.getParentFile().exists()) {
             if (!localFile.getParentFile().exists()) {
                 localFile.getParentFile().mkdirs();
                 localFile.getParentFile().mkdirs();
             }
             }
+            if(localFile.isDirectory()){
+                String fileName = remoteFilePath.substring(remoteFilePath.lastIndexOf("/")+1);
+                log.info("未配置文件名,使用默认文件名:{}",fileName);
+                localPath = localPath.concat(File.separator).concat(fileName);
+            }
 			GetObjectRequest request = new GetObjectRequest(bucket, remoteFilePath);
 			GetObjectRequest request = new GetObjectRequest(bucket, remoteFilePath);
 			s3.getObject(request,new File(localPath));
 			s3.getObject(request,new File(localPath));
         } catch (Throwable throwable) {
         } catch (Throwable throwable) {