Ver código fonte

汽车之家

dsx 2 anos atrás
pai
commit
d2d50cd656

+ 1 - 14
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/CreateObjUtil.java

@@ -1,7 +1,6 @@
 package com.fdkankan.common.util;
 
-import cn.hutool.core.exceptions.ExceptionUtil;
-import cn.hutool.core.io.FileTypeUtil;
+import cn.hutool.core.date.StopWatch;
 import com.fdkankan.common.constant.ConstantFileName;
 import com.fdkankan.common.constant.ConstantFilePath;
 import com.fdkankan.common.proto.BigSceneProto;
@@ -9,19 +8,7 @@ import com.fdkankan.common.proto.Common;
 import com.fdkankan.common.proto.Visionmodeldata;
 import com.fdkankan.common.proto.format.JsonFormat;
 import com.google.protobuf.TextFormat;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 import lombok.extern.slf4j.Slf4j;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.util.StopWatch;
 
 import java.io.*;
 import java.util.HashMap;

+ 82 - 81
4dkankan-utils-fyun/src/main/java/com/fdkankan/fyun/oss/UploadToOssUtil.java

@@ -108,30 +108,30 @@ public class UploadToOssUtil {
 	private static final String UPLOAD_FFILE_SH = "bash /opt/ossutil/upload-file.sh %s %s %s";
 
 	//上传的数据是byte[],key是上传后的文件名
-	public void upload(byte[] data,String key1) throws IOException{
+	public void upload(String bucket, byte[] data,String key1) throws IOException{
 		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , new String(data, "UTF-8"),key1,type);
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
 			case OSS:
-				uploadOss(data,key1);
+				uploadOss(bucket, data,key1);
 				break;
 			case AWS:
-				uploadAws(data,key1);
+				uploadAws(bucket, data,key1);
 				break;
 			case LOCAL:
-				uploadLocal(data,key1);
+				uploadLocal(bucket, data,key1);
 				break;
 		}
 	}
-	public void upload(String filePath, String key1) {
+	public void upload(String bucket, String filePath, String key1) {
 		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , filePath,key1,type);
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
 			case OSS:
-				uploadOss(filePath,key1);
+				uploadOss(bucket, filePath,key1);
 				break;
 			case AWS:
-				uploadAws(filePath,key1);
+				uploadAws(bucket, filePath,key1);
 				break;
 			case LOCAL:
 				uploadLocal(filePath,key1);
@@ -174,26 +174,26 @@ public class UploadToOssUtil {
 	}
 
 
-	public void uploadSdk(String filePath, String key1) {
+	public void uploadSdk(String bucket, String filePath, String key1) {
 		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , filePath,key1,type);
 		switch (type){
-			case "oss":uploadSdkOss(filePath,key1); break;
-			case "aws": uploadAws(filePath,key1); break;
+			case "oss":uploadSdkOss(bucket, filePath,key1); break;
+			case "aws": uploadAws(bucket, filePath,key1); break;
 			case "local":uploadLocal(filePath,key1);  break;
 		}
 	}
-	public void upload2(String filePath, String key1) {
+	public void upload2(String bucket, String filePath, String key1) {
 		log.info("开始上传文件 源路径:{},目标路径:{},type:{}" , filePath,key1,type);
 		switch (type){
-			case "oss":upload2Oss(filePath,key1); break;
-			case "aws": uploadAws(filePath,key1); break;
+			case "oss":upload2Oss(bucket, filePath,key1); break;
+			case "aws": uploadAws(bucket, filePath,key1); break;
 			case "local":uploadLocal(filePath,key1);  break;
 		}
 	}
-	public void delete(String key1) throws IOException{
+	public void delete(String bucket, String key1) throws IOException{
 		switch (type){
-			case "oss":deleteOss(key1); break;
-			case "aws": deleteS3Object(key1); break;
+			case "oss":deleteOss(bucket, key1); break;
+			case "aws": deleteS3Object(bucket, key1); break;
 			case "local":FileUtil.del(key1);  break;
 		}
 	}
@@ -203,16 +203,16 @@ public class UploadToOssUtil {
 	 * @param prefix
 	 * @return
 	 */
-	public int deleteFile(String prefix){
+	public int deleteFile(String bucket, String prefix){
 		switch (type){
-			case "oss":deleteOssFile(prefix); break;
-			case "aws": deleteAwsFile(prefix); break;
+			case "oss":deleteOssFile(bucket, prefix); break;
+			case "aws": deleteAwsFile(bucket, prefix); break;
 			case "local":FileUtil.del(prefix);  break;
 		}
 		return 1;
 	}
 
-	public void deleteOss(String objectName){
+	public void deleteOss(String bucket, String objectName){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			ossClient.deleteObject(bucket, objectName);
@@ -225,7 +225,7 @@ public class UploadToOssUtil {
 		}
 	}
 
-	public void deleteOssFile(String prefix){
+	public void deleteOssFile(String bucket, String prefix){
 		int maxKeys = 200;
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
@@ -234,7 +234,7 @@ public class UploadToOssUtil {
 			ObjectListing objectListing;
 
 			do {
-				objectListing = ossClient.listObjects(new ListObjectsRequest(this.bucket).withPrefix(prefix).withMarker(nextMarker).withMaxKeys(maxKeys));
+				objectListing = ossClient.listObjects(new ListObjectsRequest(bucket).withPrefix(prefix).withMarker(nextMarker).withMaxKeys(maxKeys));
 				List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
 				if (CollUtil.isEmpty(sums)) {
 					return;
@@ -283,7 +283,7 @@ public class UploadToOssUtil {
 		}
 	}
 
-	private void deleteAwsFile(String prefix){
+	private void deleteAwsFile(String bucket, String prefix){
 
 		int maxKeys = 200;
 		String nextMaker = null;
@@ -296,7 +296,7 @@ public class UploadToOssUtil {
 			.build();
 		try {
 			com.amazonaws.services.s3.model.ListObjectsRequest listObjectsRequest = new com.amazonaws.services.s3.model.ListObjectsRequest();
-			listObjectsRequest.setBucketName(this.bucket);
+			listObjectsRequest.setBucketName(bucket);
 			listObjectsRequest.setPrefix(prefix);
 			listObjectsRequest.setMaxKeys(maxKeys);
 
@@ -308,7 +308,7 @@ public class UploadToOssUtil {
 				List<KeyVersion> keys =objectSummaries.stream().map(summary->new KeyVersion(summary.getKey())).collect(Collectors.toList());
 
 				com.amazonaws.services.s3.model.DeleteObjectsRequest multiObjectDeleteRequest =
-					new com.amazonaws.services.s3.model.DeleteObjectsRequest(this.bucket)
+					new com.amazonaws.services.s3.model.DeleteObjectsRequest(bucket)
 					.withKeys(keys)
 					.withQuiet(false);
 				com.amazonaws.services.s3.model.DeleteObjectsResult delObjRes = s3.deleteObjects(multiObjectDeleteRequest);
@@ -325,7 +325,7 @@ public class UploadToOssUtil {
 		}
 	}
 
-	public void uploadOss(byte[] data,String objectName){
+	public void uploadOss(String bucket, byte[] data,String objectName){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			ossClient.putObject(bucket, objectName, new ByteArrayInputStream(data));
@@ -337,7 +337,7 @@ public class UploadToOssUtil {
 			}
 		}
 	}
-	public void uploadAws(byte[] data,String objectName){
+	public void uploadAws(String bucket, byte[] data,String objectName){
 		log.info("s3key=" + s3key);
 		log.info("s3secrey=" + s3secrey);
 		BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrey);
@@ -350,7 +350,7 @@ public class UploadToOssUtil {
 			.build();
 		try {
 			com.amazonaws.services.s3.model.ObjectMetadata metadata = new com.amazonaws.services.s3.model.ObjectMetadata();
-			PutObjectRequest request = new PutObjectRequest(this.bucket, objectName, new ByteArrayInputStream(data), metadata);
+			PutObjectRequest request = new PutObjectRequest(bucket, objectName, new ByteArrayInputStream(data), metadata);
 			request.withCannedAcl(CannedAccessControlList.PublicRead);
 			s3.putObject(request);
 		}catch (Exception e){
@@ -361,7 +361,7 @@ public class UploadToOssUtil {
 			}
 		}
 	}
-	public void uploadLocal(byte[] data,String key1){
+	public void uploadLocal(String bucket, byte[] data,String key1){
 		InputStream in = new ByteArrayInputStream(data);
 		File file = new File(key1);
 		String path = key1.substring(0, key1.lastIndexOf("/"));
@@ -391,7 +391,7 @@ public class UploadToOssUtil {
 	}
 
 
-	public void uploadOss(String filePath, String key1){
+	public void uploadOss(String bucket, String filePath, String key1){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			File file = new File(filePath);
@@ -412,9 +412,9 @@ public class UploadToOssUtil {
 		}
 	}
 
-	public void uploadAws(String filePath, String key1){
+	public void uploadAws(String bucket, String filePath, String key1){
 		try{
-			uploadS3File(filePath, key1);
+			uploadS3File(bucket, filePath, key1);
 		}catch (Exception e){
 			e.printStackTrace();
 		}
@@ -430,7 +430,7 @@ public class UploadToOssUtil {
 	}
 
 
-	public void uploadSdkOss(String filePath, String key1){
+	public void uploadSdkOss(String bucket, String filePath, String key1){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			File file = new File(filePath);
@@ -442,14 +442,14 @@ public class UploadToOssUtil {
 			if(filePath.contains(".jpg")){
 				metadata.setContentType("image/jpeg");
 			}
-			ossClient.putObject(bucketSdk, key1, new File(filePath), metadata);
+			ossClient.putObject(bucket, key1, new File(filePath), metadata);
 
 		} catch (Exception e) {
 			log.error(e.toString() + filePath);
 		}
 	}
 
-	public void upload2Oss(String filePath, String key1){
+	public void upload2Oss(String bucket, String filePath, String key1){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			ObjectMetadata metadata = new ObjectMetadata();
@@ -469,7 +469,7 @@ public class UploadToOssUtil {
 	}
 
 	//上传的数据是文件夹,参数是文件夹路径,key是上传后的文件名
-	public void uploadMulFiles(Map<String, String> filepaths) {
+	public void uploadMulFiles(String bucket, Map<String, String> filepaths) {
 		if (filepaths == null) {
 			return;
 		}
@@ -477,11 +477,11 @@ public class UploadToOssUtil {
 		log.info("开始批量上传文件:");
 		if (filepaths.size() > 50) {
 			filepaths.entrySet().parallelStream().forEach(entry->{
-				upload2(entry.getKey(), entry.getValue());
+				upload2(bucket, entry.getKey(), entry.getValue());
 			});
 		} else {
 			filepaths.entrySet().parallelStream().forEach(entry->{
-				upload(entry.getKey(), entry.getValue());
+				upload(bucket, entry.getKey(), entry.getValue());
 			});
 		}
 		log.info("批量上传文件结束,用时:{}" ,(System.currentTimeMillis() - start));
@@ -489,7 +489,7 @@ public class UploadToOssUtil {
 
 
 
-	public Map<String, String> getUploadS3Url(List<String> urls){
+	public Map<String, String> getUploadS3Url(String bucket, List<String> urls){
 		if(urls == null || urls.size() <= 0){
 			return null;
 		}
@@ -520,7 +520,7 @@ public class UploadToOssUtil {
 //						.withExpiration(expiration)
 //						.withContentType("image/jpeg");
 //			}else {
-				generatePresignedUrlRequest = new GeneratePresignedUrlRequest(s3bucket, path)
+				generatePresignedUrlRequest = new GeneratePresignedUrlRequest(bucket, path)
 						.withMethod(HttpMethod.PUT)
 						.withExpiration(expiration);
 //			}
@@ -531,7 +531,7 @@ public class UploadToOssUtil {
 	}
 
 
-	public String upload5(String filePath, String key1) {
+	public String upload5(String bucket, String filePath, String key1) {
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		PutObjectResult result = null;
 		try {
@@ -566,7 +566,7 @@ public class UploadToOssUtil {
 	 * @param file       文件
 	 * @param updatePath 上传路径[ eg: xxx/xxx ]
 	 */
-	public String updateS3LoadFile(MultipartFile file, String updatePath) {
+	public String updateS3LoadFile(String bucket, MultipartFile file, String updatePath) {
 
 		if (isEmpty(file)) {
 			return null;
@@ -593,7 +593,7 @@ public class UploadToOssUtil {
 			String key = updatePath;
 
 			// 设置文件并设置公读
-			PutObjectRequest request = new PutObjectRequest(s3bucket, key, localFile);
+			PutObjectRequest request = new PutObjectRequest(bucket, key, localFile);
 			request.withCannedAcl(CannedAccessControlList.PublicRead);
 
 			// 上传文件
@@ -615,7 +615,7 @@ public class UploadToOssUtil {
 	 * @param key1
 	 * @throws IOException
      */
-	private void uploadS3File(String filePath, String key1) throws Exception {
+	private void uploadS3File(String bucket, String filePath, String key1) throws Exception {
 		/**
 		 * 创建s3对象
 		 */
@@ -641,7 +641,7 @@ public class UploadToOssUtil {
 			if(filePath.contains(".png")){
 				metadata.setContentType("image/png");
 			}
-			PutObjectRequest request = new PutObjectRequest(s3bucket, key1, file);
+			PutObjectRequest request = new PutObjectRequest(bucket, key1, file);
 			request.withCannedAcl(CannedAccessControlList.PublicRead);
 			request.withMetadata(metadata);
 
@@ -664,7 +664,7 @@ public class UploadToOssUtil {
 	 * @param objectName 文件路径[ eg: /head/xxxx.jpg ]
 	 * @return
 	 */
-	public void deleteS3Object(String objectName) {
+	public void deleteS3Object(String bucket, String objectName) {
 
 		/**
 		 * 创建s3对象
@@ -682,7 +682,7 @@ public class UploadToOssUtil {
 		}
 
 		try {
-			s3.deleteObject(s3bucket, objectName);
+			s3.deleteObject(bucket, objectName);
 		} catch (Exception e) {
 			log.error("s3删除文件失败,key="+objectName, e);
 		}finally {
@@ -753,13 +753,13 @@ public class UploadToOssUtil {
 		return item;
 	}
 
-	public List<String> listKeys(String sourcePath){
+	public List<String> listKeys(String bucket, String sourcePath){
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
 			case OSS:
-				return this.listKeysFromAli(sourcePath);
+				return this.listKeysFromAli(bucket, sourcePath);
 			case AWS:
-				return this.listKeysFromAws(sourcePath);
+				return this.listKeysFromAws(bucket, sourcePath);
 			case LOCAL:
 				return this.listKeysFromLocal(sourcePath);
 		}
@@ -770,13 +770,13 @@ public class UploadToOssUtil {
 	 * 获得文件列表-阿里云
 	 * @return
 	 */
-	public List<String> listKeysFromAli(String sourcePath) {
+	public List<String> listKeysFromAli(String bucket, String sourcePath) {
 		List<String> keyList = new ArrayList<>();
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			boolean flag = true;
 			String nextMaker = null;
-			ListObjectsRequest listObjectsRequest = new ListObjectsRequest(this.bucket);
+			ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucket);
 			//指定下一级文件
 			listObjectsRequest.setPrefix(sourcePath);
 			//设置分页的页容量
@@ -815,7 +815,7 @@ public class UploadToOssUtil {
 	 * 获得文件列表-亚马逊
 	 * @return
 	 */
-	public List<String> listKeysFromAws(String sourcePath) {
+	public List<String> listKeysFromAws(String bucket, String sourcePath) {
 		List<String> keyList = new ArrayList<>();
 
 		BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrey);
@@ -830,7 +830,7 @@ public class UploadToOssUtil {
 			boolean flag = true;
 			String nextMaker = null;
 			com.amazonaws.services.s3.model.ListObjectsRequest listObjectsRequest = new com.amazonaws.services.s3.model.ListObjectsRequest();
-			listObjectsRequest.setBucketName(this.bucket);
+			listObjectsRequest.setBucketName(bucket);
 			listObjectsRequest.setPrefix(sourcePath);
 			listObjectsRequest.setMaxKeys(200);
 
@@ -875,14 +875,14 @@ public class UploadToOssUtil {
 	 * @param sourcePath
 	 * @param targetPath
 	 **/
-	public void copyFiles(String sourcePath, String targetPath) throws IOException {
+	public void copyFiles(String bucket, String sourcePath, String targetPath) throws IOException {
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
 			case OSS:
-				this.copyFilesFromAli(sourcePath, targetPath);
+				this.copyFilesFromAli(bucket, sourcePath, targetPath);
 				break;
 			case AWS:
-				this.copyFilesFromAws(sourcePath, targetPath);
+				this.copyFilesFromAws(bucket, sourcePath, targetPath);
 				break;
 			case LOCAL: this.copyFilesFromLocal(sourcePath, targetPath);
 		}
@@ -897,14 +897,14 @@ public class UploadToOssUtil {
 	 * @param sourceKey
 	 * @param targetKey
 	 **/
-	public void copyObject(String sourceKey, String targetKey) throws IOException {
+	public void copyObject(String bucket, String sourceKey, String targetKey) throws IOException {
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
 			case OSS:
-				this.copyObjectFromAli(sourceKey, targetKey);
+				this.copyObjectFromAli(bucket, sourceKey, targetKey);
 				break;
 			case AWS:
-				this.copyObjectFromAws(sourceKey, targetKey);
+				this.copyObjectFromAws(bucket, sourceKey, targetKey);
 				break;
 		}
 	}
@@ -918,13 +918,13 @@ public class UploadToOssUtil {
 	 * @param sourcePath
 	 * @param targetPath
 	 **/
-	public void copyObjectFromAli(String sourcePath, String targetPath) throws IOException {
+	public void copyObjectFromAli(String bucket, String sourcePath, String targetPath) throws IOException {
 
 		// 创建OSSClient实例。
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		// 复制文件
 		log.info("开始复制:" + sourcePath);
-		ossClient.copyObject(this.bucket, sourcePath, this.bucket, targetPath);
+		ossClient.copyObject(bucket, sourcePath, bucket, targetPath);
 		log.info("复制成功:" + sourcePath);
 		ossClient.shutdown();
 	}
@@ -940,10 +940,10 @@ public class UploadToOssUtil {
 	 * @param sourcePath
 	 * @param targetPath
 	 **/
-	public void copyFilesFromAli(String sourcePath, String targetPath) throws IOException {
+	public void copyFilesFromAli(String bucket, String sourcePath, String targetPath) throws IOException {
 
 		//获取源文件列表
-		List<String> sourceKeyList = this.listKeysFromAli(sourcePath);
+		List<String> sourceKeyList = this.listKeysFromAli(bucket, sourcePath);
 		if(CollUtil.isEmpty(sourceKeyList)){
 			return;
 		}
@@ -952,7 +952,7 @@ public class UploadToOssUtil {
 		// 复制文件
 		sourceKeyList.parallelStream().forEach(key -> {
 			log.info("开始复制:" + key);
-			ossClient.copyObject(this.bucket, key, this.bucket, key.replace(sourcePath, targetPath));
+			ossClient.copyObject(bucket, key, bucket, key.replace(sourcePath, targetPath));
 			log.info("复制成功:" + key);
 		});
 
@@ -969,10 +969,10 @@ public class UploadToOssUtil {
 	 * @param sourcePath
 	 * @param targetPath
 	 **/
-	public void copyFilesFromAws(String sourcePath, String targetPath){
+	public void copyFilesFromAws(String bucket, String sourcePath, String targetPath){
 
 		try {
-			List<String> sourceKeyList = this.listKeysFromAws(sourcePath);
+			List<String> sourceKeyList = this.listKeysFromAws(bucket, sourcePath);
 			/**
 			 * 创建s3对象
 			 */
@@ -988,7 +988,7 @@ public class UploadToOssUtil {
 			sourceKeyList.parallelStream().forEach(key -> {
 				log.info("开始复制:" + key);
 				com.amazonaws.services.s3.model.CopyObjectRequest request =
-					new com.amazonaws.services.s3.model.CopyObjectRequest(this.bucket, key, this.bucket, key.replace(sourcePath, targetPath));
+					new com.amazonaws.services.s3.model.CopyObjectRequest(bucket, key, bucket, key.replace(sourcePath, targetPath));
 				request.withCannedAccessControlList(CannedAccessControlList.PublicRead);
 				s3.copyObject(request);
 				log.info("复制成功:" + key);
@@ -1008,7 +1008,7 @@ public class UploadToOssUtil {
 	 * @param sourceKey
 	 * @param targetKey
 	 **/
-	public void copyObjectFromAws(String sourceKey, String targetKey){
+	public void copyObjectFromAws(String bucket, String sourceKey, String targetKey){
 			BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrey);
 			AmazonS3 s3 = AmazonS3ClientBuilder.standard()
 				.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
@@ -1018,7 +1018,7 @@ public class UploadToOssUtil {
 				.build();
 			// 复制文件
 			log.info("开始复制:" + sourceKey);
-			s3.copyObject(this.bucket, sourceKey, this.bucket, targetKey);
+			s3.copyObject(this.bucket, sourceKey, bucket, targetKey);
 			log.info("复制成功:" + sourceKey);
 			s3.shutdown();
 	}
@@ -1050,6 +1050,7 @@ public class UploadToOssUtil {
 				return this.getObjectContentFromAli(bucketName, objectName);
 			case AWS:
 				return this.getObjectContentFromAws(bucketName, objectName);
+
 			case LOCAL:
 				return this.getObjectContentFromLocal(objectName);
 		}
@@ -1096,7 +1097,7 @@ public class UploadToOssUtil {
 	 * @param objectName
 	 * @return
 	 */
-	public boolean existOnAli(String objectName){
+	public boolean existOnAli(String bucket, String objectName){
 		//创建oss客户端
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		// ossObject包含文件所在的存储空间名称、文件名称、文件元信息以及一个输入流。
@@ -1159,7 +1160,7 @@ public class UploadToOssUtil {
 	 * @param objectName
 	 * @return
 	 */
-	public boolean existOnAws(String objectName){
+	public boolean existOnAws(String bucket, String objectName){
 
 		BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrey);
 		AmazonS3 s3 = AmazonS3ClientBuilder.standard()
@@ -1186,13 +1187,13 @@ public class UploadToOssUtil {
 	 * @param key
 	 * @return
 	 */
-	public boolean existKey(String key){
+	public boolean existKey(String bucket, String key){
 		StorageType storageType = StorageType.get(type);
 		switch (storageType){
 			case OSS:
-				return this.existOnAli(key);
+				return this.existOnAli(bucket, key);
 			case AWS:
-				return this.existOnAws(key);
+				return this.existOnAws(bucket, key);
 			default:
 				return false;
 		}
@@ -1213,13 +1214,13 @@ public class UploadToOssUtil {
 	 * @param objectName
 	 * @param localPath
 	 */
-	public boolean download(String objectName, String localPath){
+	public boolean download(String bucket, String objectName, String localPath){
 		StorageType storageType = StorageType.get(this.type);
 		switch (storageType){
 			case OSS:
-				return this.downFormAli(objectName, localPath);
+				return this.downFormAli(bucket, objectName, localPath);
 			case AWS:
-				return this.downFromS3(objectName, localPath);
+				return this.downFromS3(bucket, objectName, localPath);
 		}
 		return false;
 	}
@@ -1230,7 +1231,7 @@ public class UploadToOssUtil {
 	 * @param localPath 本地文件地址
 	 * @return
 	 */
-	public boolean downFormAli(String objectName, String localPath){
+	public boolean downFormAli(String bucket, String objectName, String localPath){
 		OSSClient ossClient = new OSSClient(point, key, secrey);
 		try {
 			com.aliyun.oss.model.GetObjectRequest request  = new com.aliyun.oss.model.GetObjectRequest(bucket,objectName);
@@ -1252,7 +1253,7 @@ public class UploadToOssUtil {
 	 * @param localPath 本地文件地址
 	 * @return
 	 */
-	public boolean downFromS3(String objectName, String localPath) {
+	public boolean downFromS3(String bucket, String objectName, String localPath) {
 		BasicAWSCredentials awsCreds = new BasicAWSCredentials(s3key, s3secrey);
 		AmazonS3 s3 = AmazonS3ClientBuilder.standard()
 			.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
@@ -1261,7 +1262,7 @@ public class UploadToOssUtil {
 				new EndpointConfiguration(this.point, null))
 			.build();
 		try {
-			GetObjectRequest request  = new GetObjectRequest(this.bucket,objectName);
+			GetObjectRequest request  = new GetObjectRequest(bucket,objectName);
 			s3.getObject(request,new File(localPath));
 			return true;
 		} catch (Exception e) {