| 
															
																@@ -5,13 +5,12 @@ import com.aliyun.oss.OSS; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import com.aliyun.oss.OSSClient; 
															 | 
															
															 | 
															
																 import com.aliyun.oss.OSSClient; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import com.aliyun.oss.model.*; 
															 | 
															
															 | 
															
																 import com.aliyun.oss.model.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.apache.commons.lang.StringUtils; 
															 | 
															
															 | 
															
																 import org.apache.commons.lang.StringUtils; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-import org.jeecg.modules.wps.propertie.OSSProperties; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.jeecg.modules.wps.util.file.FileType; 
															 | 
															
															 | 
															
																 import org.jeecg.modules.wps.util.file.FileType; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.jeecg.modules.wps.util.file.FileTypeJudge; 
															 | 
															
															 | 
															
																 import org.jeecg.modules.wps.util.file.FileTypeJudge; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.jeecg.modules.wps.util.file.FileUtil; 
															 | 
															
															 | 
															
																 import org.jeecg.modules.wps.util.file.FileUtil; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.jeecg.modules.wps.util.upload.ResFileDTO; 
															 | 
															
															 | 
															
																 import org.jeecg.modules.wps.util.upload.ResFileDTO; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-import org.springframework.beans.factory.annotation.Autowired; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-import org.springframework.stereotype.Service; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.beans.factory.annotation.Value; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+import org.springframework.stereotype.Component; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import org.springframework.web.multipart.MultipartFile; 
															 | 
															
															 | 
															
																 import org.springframework.web.multipart.MultipartFile; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import java.io.File; 
															 | 
															
															 | 
															
																 import java.io.File; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -21,46 +20,93 @@ import java.io.InputStream; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import java.net.URL; 
															 | 
															
															 | 
															
																 import java.net.URL; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 import java.util.*; 
															 | 
															
															 | 
															
																 import java.util.*; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-@Service 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-public class OSSUtil { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+@Component 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+public class WpsOSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String fileUrlPrefix; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     * 阿里云API的bucket名称 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String bucketName; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String diskName; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String regionId; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     * 阿里云API的内或外网域名 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String endpoint; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     * 阿里云API的密钥Access Key ID 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String accessKey; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    /** 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     * 阿里云API的密钥Access Key Secret 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static String accessSecret; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.file_url_prefix}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static void setFileUrlPrefix(String fileUrlPrefix) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.fileUrlPrefix = fileUrlPrefix; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.disk_name}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static void setDiskName(String diskName) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.diskName = diskName; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.region_Id}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static void setRegionId(String regionId) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.regionId = regionId; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.bucket_name}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public void setBucketName(String bucketName) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.bucketName = bucketName; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.access_key}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public void setAccessKey(String accessKey) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.accessKey = accessKey; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    @Autowired 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    public OSSUtil(OSSProperties oss, FileTypeJudge fileTypeJudge) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        this.oss = oss; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        this.fileTypeJudge = fileTypeJudge; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.access_secret}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public void setAccessSecret(String accessSecret) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.accessSecret = accessSecret; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    @Value("${wps.oss.endpoint}") 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public void setEndpoint(String endpoint) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        WpsOSSUtil.endpoint = endpoint; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    private final OSSProperties oss; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    private final FileTypeJudge fileTypeJudge; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    private OSSClient getOSSClient(){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        return new OSSClient(oss.getEndpoint(),oss.getAccessKey(), oss.getAccessSecret()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    private static OSSClient getOSSClient(){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        return new OSSClient(endpoint,accessKey, accessSecret); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    public String simpleUploadFilePath(String filePath){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static String simpleUploadFilePath(String filePath){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         File file = new File(filePath); 
															 | 
															
															 | 
															
																         File file = new File(filePath); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        return (this.simpleUploadFile(file)); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        return simpleUploadFile(file); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    public String simpleUploadFile(File file){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static String simpleUploadFile(File file){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String fileName = file.getName(); 
															 | 
															
															 | 
															
																         String fileName = file.getName(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String newFileName = FileUtil.makeNewFileName(fileName); 
															 | 
															
															 | 
															
																         String newFileName = FileUtil.makeNewFileName(fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        this.getOSSClient().putObject(oss.getBucketName(), oss.getDiskName() + newFileName, file); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        return (oss.getFileUrlPrefix() + oss.getDiskName() + newFileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        getOSSClient().putObject(bucketName, diskName + newFileName, file); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        return (fileUrlPrefix + diskName + newFileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public String simpleUploadMultipartFile(MultipartFile file){ 
															 | 
															
															 | 
															
																     public String simpleUploadMultipartFile(MultipartFile file){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String fileName = file.getOriginalFilename(); 
															 | 
															
															 | 
															
																         String fileName = file.getOriginalFilename(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String newFileName = FileUtil.makeNewFileName(fileName); 
															 | 
															
															 | 
															
																         String newFileName = FileUtil.makeNewFileName(fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try { 
															 | 
															
															 | 
															
																         try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            this.getOSSClient().putObject(oss.getBucketName(), oss.getDiskName() + newFileName, file.getInputStream()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            getOSSClient().putObject(bucketName, diskName + newFileName, file.getInputStream()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } catch (IOException e) { 
															 | 
															
															 | 
															
																         } catch (IOException e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             e.printStackTrace(); 
															 | 
															
															 | 
															
																             e.printStackTrace(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } 
															 | 
															
															 | 
															
																         } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        return (oss.getFileUrlPrefix() + oss.getDiskName() + newFileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        return (fileUrlPrefix + diskName + newFileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    public ResFileDTO uploadMultipartFile(MultipartFile file){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static ResFileDTO uploadMultipartFile(MultipartFile file){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String fileName = file.getOriginalFilename(); 
															 | 
															
															 | 
															
																         String fileName = file.getOriginalFilename(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         InputStream inputStream; 
															 | 
															
															 | 
															
																         InputStream inputStream; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         ResFileDTO o = new ResFileDTO(); 
															 | 
															
															 | 
															
																         ResFileDTO o = new ResFileDTO(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -68,7 +114,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         long fileSize = file.getSize(); 
															 | 
															
															 | 
															
																         long fileSize = file.getSize(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try { 
															 | 
															
															 | 
															
																         try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             inputStream = file.getInputStream(); 
															 | 
															
															 | 
															
																             inputStream = file.getInputStream(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            FileType type = fileTypeJudge.getType(inputStream); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            FileType type = FileTypeJudge.getType(inputStream); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																             if(type == null || "null".equals(type.toString()) || 
															 | 
															
															 | 
															
																             if(type == null || "null".equals(type.toString()) || 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                     "XLS_DOC".equals(type.toString())|| "XLSX_DOCX".equals(type.toString()) || 
															 | 
															
															 | 
															
																                     "XLS_DOC".equals(type.toString())|| "XLSX_DOCX".equals(type.toString()) || 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -85,21 +131,17 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } 
															 | 
															
															 | 
															
																         } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try { 
															 | 
															
															 | 
															
																         try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            o = this.uploadDetailInputStream(file.getInputStream(),fileName,fileType,fileSize); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            o = uploadDetailInputStream(file.getInputStream(),fileName,fileType,fileSize); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } catch (IOException e) { 
															 | 
															
															 | 
															
																         } catch (IOException e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             e.printStackTrace(); 
															 | 
															
															 | 
															
																             e.printStackTrace(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } 
															 | 
															
															 | 
															
																         } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         return o; 
															 | 
															
															 | 
															
																         return o; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    public ResFileDTO uploadDetailInputStream (InputStream in, String fileName , String fileType, long fileSize) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																- 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static ResFileDTO uploadDetailInputStream (InputStream in, String fileName , String fileType, long fileSize) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String uuidFileName = FileUtil.getFileUUIDName(fileName,fileType); 
															 | 
															
															 | 
															
																         String uuidFileName = FileUtil.getFileUUIDName(fileName,fileType); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																- 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        String fileUrl = oss.getFileUrlPrefix() + oss.getDiskName() + uuidFileName; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																- 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        String md5key = this.uploadFile(in, uuidFileName, fileSize, oss.getBucketName(), 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                oss.getDiskName(),fileName); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        String fileUrl = fileUrlPrefix + diskName + uuidFileName; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        String md5key = uploadFile(in, uuidFileName, fileSize, bucketName, diskName,fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         ResFileDTO o = new ResFileDTO(); 
															 | 
															
															 | 
															
																         ResFileDTO o = new ResFileDTO(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																         if(md5key != null){ 
															 | 
															
															 | 
															
																         if(md5key != null){ 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -119,10 +161,10 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      * @param diskName 上传文件的目录  --bucket下文件的路径 
															 | 
															
															 | 
															
																      * @param diskName 上传文件的目录  --bucket下文件的路径 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      * @return String 唯一MD5数字签名 
															 | 
															
															 | 
															
																      * @return String 唯一MD5数字签名 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      * */ 
															 | 
															
															 | 
															
																      * */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-    public String uploadFile(InputStream inputStream, String fileName,long fileSize,String bucketName, String diskName,String localFileName) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+    public static String uploadFile(InputStream inputStream, String fileName,long fileSize,String bucketName, String diskName,String localFileName) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String resultStr = null; 
															 | 
															
															 | 
															
																         String resultStr = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try { 
															 | 
															
															 | 
															
																         try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            OSSClient client =  this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            OSSClient client =  getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             //创建上传Object的Metadata 
															 | 
															
															 | 
															
																             //创建上传Object的Metadata 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             ObjectMetadata metadata = new ObjectMetadata(); 
															 | 
															
															 | 
															
																             ObjectMetadata metadata = new ObjectMetadata(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             metadata.setContentLength(inputStream.available()); 
															 | 
															
															 | 
															
																             metadata.setContentLength(inputStream.available()); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -143,7 +185,6 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } catch (Exception e) { 
															 | 
															
															 | 
															
																         } catch (Exception e) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             e.printStackTrace(); 
															 | 
															
															 | 
															
																             e.printStackTrace(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             System.out.println("上传阿里云OSS服务器异常:"+e.getMessage()); 
															 | 
															
															 | 
															
																             System.out.println("上传阿里云OSS服务器异常:"+e.getMessage()); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            //LOG.error("上传阿里云OSS服务器异常." + e.getMessage(), e); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } 
															 | 
															
															 | 
															
																         } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         return resultStr; 
															 | 
															
															 | 
															
																         return resultStr; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -157,7 +198,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public void changeFileMetaInfo(String fileName,String bucketName,String downName){ 
															 | 
															
															 | 
															
																     public void changeFileMetaInfo(String fileName,String bucketName,String downName){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try{ 
															 | 
															
															 | 
															
																         try{ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             // 创建OSSClient实例。 
															 | 
															
															 | 
															
																             // 创建OSSClient实例。 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            OSS ossClient = this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            OSS ossClient = getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             // 设置源文件与目标文件相同,调用ossClient.copyObject方法修改文件元信息。 
															 | 
															
															 | 
															
																             // 设置源文件与目标文件相同,调用ossClient.copyObject方法修改文件元信息。 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             CopyObjectRequest request = new CopyObjectRequest(bucketName, fileName, bucketName, fileName); 
															 | 
															
															 | 
															
																             CopyObjectRequest request = new CopyObjectRequest(bucketName, fileName, bucketName, fileName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             ObjectMetadata meta = new ObjectMetadata(); 
															 | 
															
															 | 
															
																             ObjectMetadata meta = new ObjectMetadata(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -191,7 +232,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      */ 
															 | 
															
															 | 
															
																      */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public URL getDownLoadUrl(String fileName, String bucketName){ 
															 | 
															
															 | 
															
																     public URL getDownLoadUrl(String fileName, String bucketName){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         // 创建OSSClient实例。 
															 | 
															
															 | 
															
																         // 创建OSSClient实例。 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        OSS ossClient = this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        OSS ossClient = getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         //设置链接时效60分钟 
															 | 
															
															 | 
															
																         //设置链接时效60分钟 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         Calendar c = Calendar.getInstance(); 
															 | 
															
															 | 
															
																         Calendar c = Calendar.getInstance(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         c.setTime(new Date()); 
															 | 
															
															 | 
															
																         c.setTime(new Date()); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -240,7 +281,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public String uploadObject(File file, String bucketName, String diskName) { 
															 | 
															
															 | 
															
																     public String uploadObject(File file, String bucketName, String diskName) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String resultStr = null; 
															 | 
															
															 | 
															
																         String resultStr = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try { 
															 | 
															
															 | 
															
																         try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            OSSClient client =  this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            OSSClient client =  getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             InputStream is = new FileInputStream(file); 
															 | 
															
															 | 
															
																             InputStream is = new FileInputStream(file); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             String fileName = file.getName(); 
															 | 
															
															 | 
															
																             String fileName = file.getName(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             long fileSize = file.length(); 
															 | 
															
															 | 
															
																             long fileSize = file.length(); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -273,7 +314,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String uploadid = null; 
															 | 
															
															 | 
															
																         String uploadid = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         int j=0; 
															 | 
															
															 | 
															
																         int j=0; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         // 初始化一个OSSClient 
															 | 
															
															 | 
															
																         // 初始化一个OSSClient 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        OSSClient client =  this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        OSSClient client =  getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         ListMultipartUploadsRequest lmur = new ListMultipartUploadsRequest(bucketName); 
															 | 
															
															 | 
															
																         ListMultipartUploadsRequest lmur = new ListMultipartUploadsRequest(bucketName); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         // 获取Bucket内所有上传事件 
															 | 
															
															 | 
															
																         // 获取Bucket内所有上传事件 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         MultipartUploadListing listing = client.listMultipartUploads(lmur); 
															 | 
															
															 | 
															
																         MultipartUploadListing listing = client.listMultipartUploads(lmur); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -354,7 +395,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public String downloadFile(String bucketName, String diskName,String filePath) { 
															 | 
															
															 | 
															
																     public String downloadFile(String bucketName, String diskName,String filePath) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String resultStr = null; 
															 | 
															
															 | 
															
																         String resultStr = null; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         try { 
															 | 
															
															 | 
															
																         try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            OSSClient client =  this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            OSSClient client =  getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             client.getObject(new GetObjectRequest(bucketName, diskName), new File(filePath)); 
															 | 
															
															 | 
															
																             client.getObject(new GetObjectRequest(bucketName, diskName), new File(filePath)); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             client.shutdown(); 
															 | 
															
															 | 
															
																             client.shutdown(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } catch (Exception e) { 
															 | 
															
															 | 
															
																         } catch (Exception e) { 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -382,7 +423,7 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      * @param key Bucket下的文件的路径名+文件名 
															 | 
															
															 | 
															
																      * @param key Bucket下的文件的路径名+文件名 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      */ 
															 | 
															
															 | 
															
																      */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public void deleteFile( String bucketName, String diskName, String key){ 
															 | 
															
															 | 
															
																     public void deleteFile( String bucketName, String diskName, String key){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        OSSClient client =  this.getOSSClient(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        OSSClient client =  getOSSClient(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         client.deleteObject(bucketName, diskName + key); 
															 | 
															
															 | 
															
																         client.deleteObject(bucketName, diskName + key); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         client.shutdown(); 
															 | 
															
															 | 
															
																         client.shutdown(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         System.out.println("删除" + bucketName + "下的文件" + diskName + key + "成功"); 
															 | 
															
															 | 
															
																         System.out.println("删除" + bucketName + "下的文件" + diskName + key + "成功"); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -395,19 +436,45 @@ public class OSSUtil { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																      */ 
															 | 
															
															 | 
															
																      */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     public static String getContentType(String fileName){ 
															 | 
															
															 | 
															
																     public static String getContentType(String fileName){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         String fileExtension = fileName.substring(fileName.lastIndexOf(".")+1); 
															 | 
															
															 | 
															
																         String fileExtension = fileName.substring(fileName.lastIndexOf(".")+1); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("bmp".equalsIgnoreCase(fileExtension)) return "image/bmp"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("gif".equalsIgnoreCase(fileExtension)) return "image/gif"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("jpeg".equalsIgnoreCase(fileExtension) || "jpg".equalsIgnoreCase(fileExtension)  || "png".equalsIgnoreCase(fileExtension) ) return "image/jpeg"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("html".equalsIgnoreCase(fileExtension)) return "text/html"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("txt".equalsIgnoreCase(fileExtension)) return "text/plain"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("vsd".equalsIgnoreCase(fileExtension)) return "application/vnd.visio"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)) return "application/x-ppt"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension)) return "application/x-xls"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)) return "application/x-docx"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("xml".equalsIgnoreCase(fileExtension)) return "text/xml"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("pdf".equalsIgnoreCase(fileExtension)) return "application/pdf"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("mp3".equalsIgnoreCase(fileExtension)) return "audio/mp3"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-        if("mp4".equalsIgnoreCase(fileExtension)) return "video/mpeg4"; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("bmp".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "image/bmp"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("gif".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "image/gif"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("jpeg".equalsIgnoreCase(fileExtension) || "jpg".equalsIgnoreCase(fileExtension)  || "png".equalsIgnoreCase(fileExtension) ){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "image/jpeg"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("html".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "text/html"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("txt".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "text/plain"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("vsd".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "application/vnd.visio"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("ppt".equalsIgnoreCase(fileExtension) || "pptx".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "application/x-ppt"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("xls".equalsIgnoreCase(fileExtension) || "xlsx".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "application/x-xls"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("doc".equalsIgnoreCase(fileExtension) || "docx".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "application/x-docx"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("xml".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "text/xml"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("pdf".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "application/pdf"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("mp3".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "audio/mp3"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        if("mp4".equalsIgnoreCase(fileExtension)){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            return "video/mpeg4"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         return "text/html"; 
															 | 
															
															 | 
															
																         return "text/html"; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 |