| 
						
						
						
					 | 
					 | 
					@ -1,5 +1,6 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					package com.glxp.api.upload;
 | 
					 | 
					 | 
					 | 
					package com.glxp.api.upload;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import cn.hutool.core.exceptions.ExceptionUtil;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import cn.hutool.core.thread.ThreadUtil;
 | 
					 | 
					 | 
					 | 
					import cn.hutool.core.thread.ThreadUtil;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j;
 | 
					 | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import org.apache.commons.lang3.exception.ExceptionUtils;
 | 
					 | 
					 | 
					 | 
					import org.apache.commons.lang3.exception.ExceptionUtils;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -15,6 +16,7 @@ import java.io.File;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.io.FileInputStream;
 | 
					 | 
					 | 
					 | 
					import java.io.FileInputStream;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.io.IOException;
 | 
					 | 
					 | 
					 | 
					import java.io.IOException;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.io.OutputStream;
 | 
					 | 
					 | 
					 | 
					import java.io.OutputStream;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					import java.nio.charset.StandardCharsets;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					@Slf4j
 | 
					 | 
					 | 
					 | 
					@Slf4j
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					@RestController
 | 
					 | 
					 | 
					 | 
					@RestController
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -27,10 +29,13 @@ public class DownloadController {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            , @RequestParam String type
 | 
					 | 
					 | 
					 | 
					            , @RequestParam String type
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            , @RequestParam String name) throws IOException {
 | 
					 | 
					 | 
					 | 
					            , @RequestParam String name) throws IOException {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					//        String filePath = new String(name.getBytes("UTF-8"), "UTF-8");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (name.endsWith("pdf") || name.endsWith("doc")) {
 | 
					 | 
					 | 
					 | 
					        if (name.endsWith("pdf") || name.endsWith("doc")) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            OutputStream os = null;
 | 
					 | 
					 | 
					 | 
					            OutputStream os = null;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            try {
 | 
					 | 
					 | 
					 | 
					            try {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                FileInputStream input = new FileInputStream(new File(filePath + "/register/file/" + type + "/" + name));
 | 
					 | 
					 | 
					 | 
					                File file = new File(filePath + "/register/file/" + type + "/" + name);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                FileInputStream input = new FileInputStream(file);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                OutputStream out = response.getOutputStream();
 | 
					 | 
					 | 
					 | 
					                OutputStream out = response.getOutputStream();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                byte[] b = new byte[2048];
 | 
					 | 
					 | 
					 | 
					                byte[] b = new byte[2048];
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                int len;
 | 
					 | 
					 | 
					 | 
					                int len;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -39,6 +44,9 @@ public class DownloadController {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                input.close();
 | 
					 | 
					 | 
					 | 
					                input.close();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } catch (IOException e) {
 | 
					 | 
					 | 
					 | 
					            } catch (IOException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                e.printStackTrace();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                log.error(e.getMessage());
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                log.error(new String(ExceptionUtil.getMessage(e).getBytes(StandardCharsets.UTF_8)));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                log.error("pdf:" + ExceptionUtils.getStackTrace(e));
 | 
					 | 
					 | 
					 | 
					                log.error("pdf:" + ExceptionUtils.getStackTrace(e));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } finally {
 | 
					 | 
					 | 
					 | 
					            } finally {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (os != null) {
 | 
					 | 
					 | 
					 | 
					                if (os != null) {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -50,8 +58,9 @@ public class DownloadController {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            OutputStream os = null;
 | 
					 | 
					 | 
					 | 
					            OutputStream os = null;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            try {
 | 
					 | 
					 | 
					 | 
					            try {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                // 读取图片
 | 
					 | 
					 | 
					 | 
					                // 读取图片
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                File file = new File(filePath + "/register/file/" + type + "/" + name);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                BufferedImage image = ImageIO.read(
 | 
					 | 
					 | 
					 | 
					                BufferedImage image = ImageIO.read(
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                        new FileInputStream(new File(filePath + "/register/file/" + type + "/" + name)));
 | 
					 | 
					 | 
					 | 
					                        new FileInputStream(file));
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                response.setContentType("image/png");
 | 
					 | 
					 | 
					 | 
					                response.setContentType("image/png");
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                os = response.getOutputStream();
 | 
					 | 
					 | 
					 | 
					                os = response.getOutputStream();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -59,6 +68,9 @@ public class DownloadController {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                    ImageIO.write(image, "png", os);
 | 
					 | 
					 | 
					 | 
					                    ImageIO.write(image, "png", os);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                }
 | 
					 | 
					 | 
					 | 
					                }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } catch (IOException e) {
 | 
					 | 
					 | 
					 | 
					            } catch (IOException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                e.printStackTrace();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                log.error(e.getMessage());
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					                log.error(new String(ExceptionUtil.getMessage(e).getBytes(StandardCharsets.UTF_8)));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                log.error("图片:" + ExceptionUtils.getStackTrace(e));
 | 
					 | 
					 | 
					 | 
					                log.error("图片:" + ExceptionUtils.getStackTrace(e));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } finally {
 | 
					 | 
					 | 
					 | 
					            } finally {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                if (os != null) {
 | 
					 | 
					 | 
					 | 
					                if (os != null) {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -85,7 +97,9 @@ public class DownloadController {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            input.close();
 | 
					 | 
					 | 
					 | 
					            input.close();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } catch (IOException e) {
 | 
					 | 
					 | 
					 | 
					        } catch (IOException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					            log.error(e.getMessage());
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.error(ExceptionUtil.getMessage(e));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.error("图片:" + ExceptionUtils.getStackTrace(e));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } finally {
 | 
					 | 
					 | 
					 | 
					        } finally {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (os != null) {
 | 
					 | 
					 | 
					 | 
					            if (os != null) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                os.flush();
 | 
					 | 
					 | 
					 | 
					                os.flush();
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -110,7 +124,9 @@ public class DownloadController {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            }
 | 
					 | 
					 | 
					 | 
					            }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            input.close();
 | 
					 | 
					 | 
					 | 
					            input.close();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } catch (IOException e) {
 | 
					 | 
					 | 
					 | 
					        } catch (IOException e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					            log.error(e.getMessage());
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.error(ExceptionUtil.getMessage(e));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.error("图片:" + ExceptionUtils.getStackTrace(e));
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } finally {
 | 
					 | 
					 | 
					 | 
					        } finally {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (os != null) {
 | 
					 | 
					 | 
					 | 
					            if (os != null) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                os.flush();
 | 
					 | 
					 | 
					 | 
					                os.flush();
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |