tianboguang 3 лет назад
Родитель
Сommit
c39258b147

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

@@ -186,11 +186,11 @@ public class OssFileService extends AbstractFYunFileService {
     }
 
     @Override
-    public void copyFileBetweenFyun(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) throws Exception {
-        copyFileBetweenFyun(sourceBucketName, sourcePath, targetBucketName, targetPath, true);
+    public void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) throws Exception {
+        copyFileBetweenBucket(sourceBucketName, sourcePath, targetBucketName, targetPath, true);
     }
 
-    private void copyFileBetweenFyun(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath, Boolean shutdown) throws Exception {
+    private void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath, Boolean shutdown) throws Exception {
         try {
             List<String> files = listRemoteFiles(sourceBucketName, sourcePath, false);
             if (ObjectUtils.isEmpty(files)) {
@@ -209,13 +209,13 @@ public class OssFileService extends AbstractFYunFileService {
     }
 
     @Override
-    public void copyFilesBetweenFyun(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) throws Exception {
+    public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) throws Exception {
         if (ObjectUtils.isEmpty(pathMap)) {
             return;
         }
         try {
             for (Map.Entry<String, String> entry : pathMap.entrySet()) {
-                copyFileBetweenFyun(sourceBucketName, entry.getKey(), targetBucketName, entry.getValue(), false);
+                copyFileBetweenBucket(sourceBucketName, entry.getKey(), targetBucketName, entry.getValue(), false);
             }
         } catch (Exception e) {
             log.error("批量复制文件失败!");

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

@@ -25,8 +25,8 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
     }
 
     @Override
-    public void uploadFile(String filePath, String remoteFilePath,Map<String,String> headers) throws Exception{
-        uploadFile(fYunFileConfig.getBucket(),filePath,remoteFilePath,headers);
+    public void uploadFile(String filePath, String remoteFilePath, Map<String, String> headers) throws Exception {
+        uploadFile(fYunFileConfig.getBucket(), filePath, remoteFilePath, headers);
     }
 
     @Override
@@ -54,14 +54,22 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
         return listRemoteFiles(fYunFileConfig.getBucket(), sourcePath);
     }
 
+    public void copyFileInBucket(String sourcePath, String targetPath) throws Exception {
+        copyFileBetweenBucket(fYunFileConfig.getBucket(), sourcePath, fYunFileConfig.getBucket(), targetPath);
+    }
+
+    public void copyFileInBucket(String bucket, String sourcePath, String targetPath) throws Exception {
+        copyFileBetweenBucket(bucket, sourcePath, bucket, targetPath);
+    }
+
     @Override
-    public void copyFileBetweenFyun(String sourcePath, String targetBucketName, String targetPath) throws Exception {
-        copyFileBetweenFyun(fYunFileConfig.getBucket(),sourcePath, targetBucketName, targetPath);
+    public void copyFileBetweenBucket(String sourcePath, String targetBucketName, String targetPath) throws Exception {
+        copyFileBetweenBucket(fYunFileConfig.getBucket(), sourcePath, targetBucketName, targetPath);
     }
 
     @Override
-    public void copyFilesBetweenFyun(String targetBucketName, Map<String, String> pathMap) throws Exception {
-        copyFilesBetweenFyun(fYunFileConfig.getBucket(),targetBucketName,pathMap);
+    public void copyFilesBetweenBucket(String targetBucketName, Map<String, String> pathMap) throws Exception {
+        copyFilesBetweenBucket(fYunFileConfig.getBucket(), targetBucketName, pathMap);
     }
 
     @Override
@@ -76,6 +84,6 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
 
     @Override
     public void downloadFile(String remoteFilePath, String localPath) throws Exception {
-        downloadFile(fYunFileConfig.getBucket(),remoteFilePath,localPath);
+        downloadFile(fYunFileConfig.getBucket(), remoteFilePath, localPath);
     }
 }

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

@@ -9,236 +9,270 @@ import java.util.Map;
 @Component
 public interface FYunFileServiceInterface {
 
-	/**
-	 *  上传文件
-	 * @param bucket 目标bucket
-	 * @param data 上传的数据
-	 * @param remoteFilePath 上传后的文件路径
-	 * @throws Exception
-	 */
-	void uploadFile(String bucket, byte[] data, String remoteFilePath) throws Exception;
-
-	/**
-	 *  上传文件至系统默认bucket
-	 * @param data 上传的数据
-	 * @param remoteFilePath 上传后的文件路径
-	 * @throws Exception
-	 */
-	void uploadFile(byte[] data, String remoteFilePath) throws Exception;
-
-	/**
-	 * 上传本地文件
-	 * @param bucket 目标bucket
-	 * @param filePath 本地路径
-	 * @param remoteFilePath 上传后的文件路径
-	 * @throws Exception
-	 */
-	void uploadFile(String bucket, String filePath, String remoteFilePath) throws Exception;
-
-	/**
-	 * 上传本地文件至系统默认bucket
-	 * @param filePath 本地路径
-	 * @param remoteFilePath 上传后的文件路径
-	 * @throws Exception
-	 */
-	void uploadFile(String filePath, String remoteFilePath) throws Exception;
-
-	/**
-	 * 上传本地文件
-	 * @param bucket 目标bucket
-	 * @param filePath 本地路径
-	 * @param remoteFilePath 上传后的文件路径
-	 * @throws Exception
-	 */
-	void uploadFile(String bucket, String filePath, String remoteFilePath,Map<String,String> headers) throws Exception;
-
-	/**
-	 * 上传本地文件至系统默认bucket
-	 * @param filePath 本地路径
-	 * @param remoteFilePath 上传后的文件路径
-	 * @throws Exception
-	 */
-	void uploadFile(String filePath, String remoteFilePath,Map<String,String> headers) throws Exception;
-
-	/**
-	 * 通过本地脚本上传
-	 *
-	 * @param filePath
-	 * @param remoteFilePath
-	 */
-	void uploadFileByCommand(String bucket, String filePath, String remoteFilePath) throws Exception;
-
-	/**
-	 * 通过本地脚本上传至系统默认bucket
-	 *
-	 * @param filePath
-	 * @param remoteFilePath
-	 */
-	void uploadFileByCommand(String filePath, String remoteFilePath) throws Exception;
-
-	/**
-	 * 删除服务器文件
-	 * @param bucket
-	 * @param remoteFilePath
-	 * @throws IOException
-	 */
-	void deleteFile(String bucket, String remoteFilePath) throws IOException;
-
-	/**
-	 * 删除系统默认bucket服务器文件
-	 * @param remoteFilePath
-	 * @throws IOException
-	 */
-	void deleteFile(String remoteFilePath) throws IOException;
-
-	/**
-	 * 删除目录
-	 * @param bucket
-	 * @param remoteFolderPath
-	 * @return
-	 */
-	void deleteFolder(String bucket, String remoteFolderPath) throws Exception;
-
-	/**
-	 * 删除系统默认bucket目录
-	 * @param remoteFolderPath
-	 * @return
-	 */
-	void deleteFolder(String remoteFolderPath) throws Exception;
-
-
-	/**
-	 * 上传多个文件
-	 * @param bucket
-	 * @param filepaths :key 本地路径,value,服务器文件路径
-	 * @throws Exception
-	 */
-	void uploadMulFiles(String bucket, Map<String, String> filepaths) throws Exception;
-
-	/**
-	 * 上传多个文件至系统默认bucket
-	 * @param filepaths :key 本地路径,value,服务器文件路径
-	 * @throws Exception
-	 */
-	void uploadMulFiles(Map<String, String> filepaths) throws Exception;
-
-
-	/**
-	 * 获取文件列表
-	 * @param bucket
-	 * @param sourcePath
-	 * @return
-	 * @throws Exception
-	 */
-	List<String> listRemoteFiles(String bucket, String sourcePath) throws Exception;
-
-	/**
-	 * 获取默认bucket文件列表
-	 * @param sourcePath
-	 * @return
-	 * @throws Exception
-	 */
-	List<String> listRemoteFiles(String sourcePath) throws Exception;
-
-
-	/**
-	 * <p>
-	 * 拷贝目录
-	 * </p>
-	 *
-	 * @param sourcePath
-	 * @param targetPath
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 **/
-	void copyFileBetweenFyun(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) throws Exception;
-
-	/**
-	 * <p>
-	 * 拷贝系统bucket目录至指定bucket
-	 * </p>
-	 *
-	 * @param sourcePath
-	 * @param targetPath
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 **/
-	void copyFileBetweenFyun(String sourcePath, String targetBucketName, String targetPath) throws Exception;
-
-	/**
-	 * <p>
-	 * 拷贝文件
-	 * </p>
-	 *
-	 * @param sourceBucketName
-	 * @param targetBucketName
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 **/
-	void copyFilesBetweenFyun(String sourceBucketName,String targetBucketName, Map<String,String> pathMap) throws Exception;
-
-	/**
-	 * <p>
-	 * 拷贝系统bucket目录至指定bucket
-	 * </p>
-	 *
-	 * @param targetBucketName
-	 * @param pathMap
-	 * @author dengsixing
-	 * @date 2022/1/18
-	 **/
-	void copyFilesBetweenFyun(String targetBucketName,Map<String,String> pathMap) throws Exception;
-
-
-	/**
-	 * 获取文件内容
-	 *
-	 * @param bucketName
-	 * @param remoteFilePath
-	 * @return
-	 */
-	String getFileContent(String bucketName, String remoteFilePath) throws Exception;
-
-	/**
-	 * 获取默认bucket内容
-	 *
-	 * @param remoteFilePath
-	 * @return
-	 */
-	String getFileContent(String remoteFilePath) throws Exception;
-
-
-	/**
-	 * 判断文件是否存在
-	 *
-	 * @param objectName
-	 * @return
-	 */
-	boolean fileExist(String bucket, String objectName) throws Exception;
-
-	/**
-	 * 判断默认bucket文件是否存在
-	 *
-	 * @param objectName
-	 * @return
-	 */
-	boolean fileExist(String objectName) throws Exception;
-
-	/**
-	 * 从指定bucket下载文件
-	 *
-	 * @param bucket
-	 * @param remoteFilePath
-	 * @param localPath
-	 * @return
-	 */
-	public void downloadFile(String bucket, String remoteFilePath, String localPath) throws Exception;
-
-	/**
-	 * 从系统默认bucket下载文件
-	 * @param remoteFilePath
-	 * @param localPath
-	 * @throws Exception
-	 */
-	public void downloadFile(String remoteFilePath, String localPath) throws Exception;
+    /**
+     * 上传文件
+     *
+     * @param bucket         目标bucket
+     * @param data           上传的数据
+     * @param remoteFilePath 上传后的文件路径
+     * @throws Exception
+     */
+    void uploadFile(String bucket, byte[] data, String remoteFilePath) throws Exception;
+
+    /**
+     * 上传文件至系统默认bucket
+     *
+     * @param data           上传的数据
+     * @param remoteFilePath 上传后的文件路径
+     * @throws Exception
+     */
+    void uploadFile(byte[] data, String remoteFilePath) throws Exception;
+
+    /**
+     * 上传本地文件
+     *
+     * @param bucket         目标bucket
+     * @param filePath       本地路径
+     * @param remoteFilePath 上传后的文件路径
+     * @throws Exception
+     */
+    void uploadFile(String bucket, String filePath, String remoteFilePath) throws Exception;
+
+    /**
+     * 上传本地文件至系统默认bucket
+     *
+     * @param filePath       本地路径
+     * @param remoteFilePath 上传后的文件路径
+     * @throws Exception
+     */
+    void uploadFile(String filePath, String remoteFilePath) throws Exception;
+
+    /**
+     * 上传本地文件
+     *
+     * @param bucket         目标bucket
+     * @param filePath       本地路径
+     * @param remoteFilePath 上传后的文件路径
+     * @throws Exception
+     */
+    void uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) throws Exception;
+
+    /**
+     * 上传本地文件至系统默认bucket
+     *
+     * @param filePath       本地路径
+     * @param remoteFilePath 上传后的文件路径
+     * @throws Exception
+     */
+    void uploadFile(String filePath, String remoteFilePath, Map<String, String> headers) throws Exception;
+
+    /**
+     * 通过本地脚本上传
+     *
+     * @param filePath
+     * @param remoteFilePath
+     */
+    void uploadFileByCommand(String bucket, String filePath, String remoteFilePath) throws Exception;
+
+    /**
+     * 通过本地脚本上传至系统默认bucket
+     *
+     * @param filePath
+     * @param remoteFilePath
+     */
+    void uploadFileByCommand(String filePath, String remoteFilePath) throws Exception;
+
+    /**
+     * 删除服务器文件
+     *
+     * @param bucket
+     * @param remoteFilePath
+     * @throws IOException
+     */
+    void deleteFile(String bucket, String remoteFilePath) throws IOException;
+
+    /**
+     * 删除系统默认bucket服务器文件
+     *
+     * @param remoteFilePath
+     * @throws IOException
+     */
+    void deleteFile(String remoteFilePath) throws IOException;
+
+    /**
+     * 删除目录
+     *
+     * @param bucket
+     * @param remoteFolderPath
+     * @return
+     */
+    void deleteFolder(String bucket, String remoteFolderPath) throws Exception;
+
+    /**
+     * 删除系统默认bucket目录
+     *
+     * @param remoteFolderPath
+     * @return
+     */
+    void deleteFolder(String remoteFolderPath) throws Exception;
+
+
+    /**
+     * 上传多个文件
+     *
+     * @param bucket
+     * @param filepaths :key 本地路径,value,服务器文件路径
+     * @throws Exception
+     */
+    void uploadMulFiles(String bucket, Map<String, String> filepaths) throws Exception;
+
+    /**
+     * 上传多个文件至系统默认bucket
+     *
+     * @param filepaths :key 本地路径,value,服务器文件路径
+     * @throws Exception
+     */
+    void uploadMulFiles(Map<String, String> filepaths) throws Exception;
+
+
+    /**
+     * 获取文件列表
+     *
+     * @param bucket
+     * @param sourcePath
+     * @return
+     * @throws Exception
+     */
+    List<String> listRemoteFiles(String bucket, String sourcePath) throws Exception;
+
+    /**
+     * 获取默认bucket文件列表
+     *
+     * @param sourcePath
+     * @return
+     * @throws Exception
+     */
+    List<String> listRemoteFiles(String sourcePath) throws Exception;
+
+
+    /**
+     *
+     *在指定bucket 内拷贝文件
+     * @param sourcePath
+     * @param targetPath
+     * @author dengsixing
+     * @date 2022/1/18
+     **/
+    void copyFileInBucket(String bucket, String sourcePath, String targetPath) throws Exception;
+
+    /**
+     * 在默认bucket 内拷贝文件
+     * @param sourcePath
+     * @param targetPath
+     * @author dengsixing
+     * @date 2022/1/18
+     **/
+    void copyFileInBucket(String sourcePath, String targetPath) throws Exception;
+
+    /**
+     * <p>
+     * 拷贝目录
+     * </p>
+     *
+     * @param sourcePath
+     * @param targetPath
+     * @author dengsixing
+     * @date 2022/1/18
+     **/
+    void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) throws Exception;
+
+    /**
+     * <p>
+     * 拷贝系统bucket目录至指定bucket
+     * </p>
+     *
+     * @param sourcePath
+     * @param targetPath
+     * @author dengsixing
+     * @date 2022/1/18
+     **/
+    void copyFileBetweenBucket(String sourcePath, String targetBucketName, String targetPath) throws Exception;
+
+    /**
+     * <p>
+     * 拷贝文件
+     * </p>
+     *
+     * @param sourceBucketName
+     * @param targetBucketName
+     * @author dengsixing
+     * @date 2022/1/18
+     **/
+    void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) throws Exception;
+
+    /**
+     * <p>
+     * 拷贝系统bucket目录至指定bucket
+     * </p>
+     *
+     * @param targetBucketName
+     * @param pathMap
+     * @author dengsixing
+     * @date 2022/1/18
+     **/
+    void copyFilesBetweenBucket(String targetBucketName, Map<String, String> pathMap) throws Exception;
+
+
+    /**
+     * 获取文件内容
+     *
+     * @param bucketName
+     * @param remoteFilePath
+     * @return
+     */
+    String getFileContent(String bucketName, String remoteFilePath) throws Exception;
+
+    /**
+     * 获取默认bucket内容
+     *
+     * @param remoteFilePath
+     * @return
+     */
+    String getFileContent(String remoteFilePath) throws Exception;
+
+
+    /**
+     * 判断文件是否存在
+     *
+     * @param objectName
+     * @return
+     */
+    boolean fileExist(String bucket, String objectName) throws Exception;
+
+    /**
+     * 判断默认bucket文件是否存在
+     *
+     * @param objectName
+     * @return
+     */
+    boolean fileExist(String objectName) throws Exception;
+
+    /**
+     * 从指定bucket下载文件
+     *
+     * @param bucket
+     * @param remoteFilePath
+     * @param localPath
+     * @return
+     */
+    public void downloadFile(String bucket, String remoteFilePath, String localPath) throws Exception;
+
+    /**
+     * 从系统默认bucket下载文件
+     *
+     * @param remoteFilePath
+     * @param localPath
+     * @throws Exception
+     */
+    public void downloadFile(String remoteFilePath, String localPath) throws Exception;
 }

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

@@ -208,11 +208,11 @@ public class S3FileService extends AbstractFYunFileService {
     }
 
     @Override
-    public void copyFileBetweenFyun(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) throws Exception {
-        copyFileBetweenFyun(sourceBucketName, sourcePath, targetBucketName, targetPath, true);
+    public void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) throws Exception {
+        copyFileBetweenBucket(sourceBucketName, sourcePath, targetBucketName, targetPath, true);
     }
 
-    private void copyFileBetweenFyun(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath, Boolean shutdown) throws Exception {
+    private void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath, Boolean shutdown) throws Exception {
         try {
             List<String> files = listRemoteFiles(sourceBucketName, sourcePath, false);
             if (ObjectUtils.isEmpty(files)) {
@@ -233,13 +233,13 @@ public class S3FileService extends AbstractFYunFileService {
     }
 
     @Override
-    public void copyFilesBetweenFyun(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) throws Exception {
+    public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) throws Exception {
         if (ObjectUtils.isEmpty(pathMap)) {
             return;
         }
         try {
             for (Map.Entry<String, String> entry : pathMap.entrySet()) {
-                copyFileBetweenFyun(sourceBucketName, entry.getKey(), targetBucketName, entry.getValue(), false);
+                copyFileBetweenBucket(sourceBucketName, entry.getKey(), targetBucketName, entry.getValue(), false);
             }
         } catch (Exception e) {
             log.error("批量复制文件失败!");