Browse Source

base64转文件

lyhzzz 3 năm trước cách đây
mục cha
commit
d1c2a0fad9

+ 21 - 10
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/oss/UploadToOssUtil.java

@@ -59,18 +59,21 @@ public class UploadToOssUtil {
 	@Value("${oss.sdk:4dscene}")
 	private String bucketSdk;
 
-	@Value("${oss.type:oss}")
+	@Value("${upload.type:oss}")
 	private String type;
 
-	@Value("${oss.s3key:AKIAWCV5QFZ3ZNELKYUY}")
+	@Value("${aws.s3key:AKIAWCV5QFZ3ZNELKYUY}")
 	private String s3key;
 
-	@Value("${oss.s3secrey:epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws}")
+	@Value("${aws.s3secrey:epS5ghyR4LJ7rxk/qJO9ZYh6m9Oz6g5haKDu4yws}")
 	private String s3secrey;
 
-	@Value("${oss.s3bucket:4dkankan}")
+	@Value("${aws.s3bucket:4dkankan}")
 	private String s3bucket;
 
+	@Value("${local.path:/home/4dkankan}")
+	private String localPath;
+
 
 	public void delete(String key1) throws IOException{
 		OSSClient ossClient = new OSSClient(point, key, secrey);
@@ -122,13 +125,16 @@ public class UploadToOssUtil {
 			}
 		}
 
-		if("s3".equals(type)){
+		if("aws".equals(type)){
 			try{
 				uploadS3File(filePath, key1);
 			}catch (Exception e){
 				e.printStackTrace();
 			}
 		}
+		if("local".equals(type)){
+			 new File(localPath + key1);
+		}
 	}
 
 	public void uploadSdk(String filePath, String key1) {
@@ -159,14 +165,16 @@ public class UploadToOssUtil {
 				log.error(e.toString() + filePath);
 			}
 		}
-
-		if("s3".equals(type)){
+		if("aws".equals(type)){
 			try{
 				uploadS3File(filePath, key1);
 			}catch (Exception e){
 				e.printStackTrace();
 			}
 		}
+		if("local".equals(type)){
+			new File(localPath + key1);
+		}
 	}
 
 	public void upload2(String filePath, String key1) {
@@ -196,13 +204,17 @@ public class UploadToOssUtil {
 			}
 		}
 
-		if("s3".equals(type)){
+		if("aws".equals(type)){
 			try{
 				uploadS3File(filePath, key1);
 			}catch (Exception e){
 				e.printStackTrace();
 			}
 		}
+
+		if("local".equals(type)){
+			new File(localPath + key1);
+		}
 	}
 
 	//上传的数据是文件夹,参数是文件夹路径,key是上传后的文件名
@@ -240,7 +252,7 @@ public class UploadToOssUtil {
 
 		}
 
-		if("s3".equals(type)){
+		if("aws".equals(type)){
 			deleteS3Object(prefix);
 		}
 		return 1;
@@ -553,7 +565,6 @@ public class UploadToOssUtil {
 	 * </p>
 	 * @author dengsixing
 	 * @date 2022/1/18
-	 * @param keyList
 	 * @param sourcePath
 	 * @param targetPath
 	 **/