dengsixing 2 bulan lalu
induk
melakukan
e60c7c861b

+ 15 - 1
4dkankan-utils-fyun-cos/src/main/java/com/fdkankan/fyun/oss/CosFileService.java

@@ -134,7 +134,7 @@ public class CosFileService extends AbstractFYunFileService {
     public void downloadFileByCommand(String bucket, String filePath, String remoteFilePath) {
         try {
             String optType = remoteFilePath.contains(".") ? "file" : "folder";
-            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.OSS.code(), optType);
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.COS.code(), optType);
             log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
             callshell(command);
             log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
@@ -144,6 +144,20 @@ public class CosFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.COS.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+            log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+        } catch (Exception e) {
+            log.error(String.format("下载文件失败, ossPath:%s, srcPath:%s", remoteFilePath, filePath), e);
+        }
+    }
+
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
             cosClient.deleteObject(bucket, remoteFilePath);

+ 5 - 0
4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java

@@ -142,6 +142,11 @@ public class HttpFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
             Map<String, Object> params = new HashMap<>();

+ 12 - 0
4dkankan-utils-fyun-local/src/main/java/com/fdkankan/fyun/local/LocalFileService.java

@@ -93,6 +93,18 @@ public class LocalFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.LOCAL.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+        } catch (Exception e) {
+            log.error("上传文件失败, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+        }
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         FileUtil.del(getOssPath(bucket, remoteFilePath));
     }

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

@@ -148,6 +148,19 @@ public class OssFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void downloadByCommand(String bucket,  String filePath, String remoteFilePath, boolean isDir) {
+        try {
+            String optType = isDir ? "folder" : "file";
+            String command = String.format(fYunConstants.DOWNLOAD_SH, bucket, remoteFilePath, filePath, FYunTypeEnum.OSS.code(), optType);
+            log.info("开始下载文件, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+            callshell(command);
+            log.info("下载文件完毕, ossPath:{}, srcPath:{}", remoteFilePath, filePath);
+        } catch (Exception e) {
+            log.error(String.format("下载文件失败, ossPath:%s, srcPath:%s", remoteFilePath, filePath), e);
+        }
+    }
+
+    @Override
     public void deleteFile(String bucket, String remoteFilePath) throws IOException {
         try {
             ossClient.deleteObject(bucket, remoteFilePath);

+ 5 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java

@@ -64,6 +64,11 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
     }
 
     @Override
+    public void downloadByCommand(String filePath, String remoteFilePath, boolean isDir) {
+        downloadByCommand(fYunFileConfig.getBucket(),filePath,remoteFilePath, isDir);
+    }
+
+    @Override
     public void deleteFile(String remoteFilePath) throws IOException {
         deleteFile(fYunFileConfig.getBucket(), remoteFilePath);
     }

+ 16 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/FYunFileServiceInterface.java

@@ -119,6 +119,22 @@ public interface FYunFileServiceInterface {
     void downloadFileByCommand(String filePath, String remoteFilePath) ;
 
     /**
+     * 通过本地脚本上传
+     *
+     * @param filePath
+     * @param remoteFilePath
+     */
+    void downloadByCommand(String filePath, String remoteFilePath, boolean isDir) ;
+
+    /**
+     * 通过本地脚本上传
+     *
+     * @param filePath
+     * @param remoteFilePath
+     */
+    void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) ;
+
+    /**
      * 通过本地脚本上传至系统默认bucket
      *
      * @param filePath