From fdbb2b73910384a19e496b85b5b4985c2d218dcc Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 17 五月 2020 14:18:53 +0800
Subject: [PATCH] 调试图片下载bug

---
 CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java b/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
index 1b17740..fa4fd41 100644
--- a/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
+++ b/CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
@@ -3,18 +3,22 @@
 import com.java110.common.dao.IFileServiceDao;
 import com.java110.config.properties.code.Java110Properties;
 import com.java110.core.base.smo.BaseServiceSMO;
+import com.java110.core.client.JSchFtpUploadTemplate;
 import com.java110.core.smo.file.IFileInnerServiceSMO;
 import com.java110.dto.file.FileDto;
+import com.java110.core.client.FtpUploadTemplate;
 import com.java110.utils.util.Base64Convert;
-import com.java110.utils.util.BeanConvertUtil;
-import com.java110.utils.util.FtpUpload;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 import sun.misc.BASE64Encoder;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.UUID;
 
 @RestController
 public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInnerServiceSMO {
@@ -25,6 +29,12 @@
     @Autowired
     private Java110Properties java110Properties;
 
+    @Autowired
+    private FtpUploadTemplate ftpUploadTemplate;
+
+    @Autowired
+    private JSchFtpUploadTemplate jSchFtpUploadTemplate;
+
 
     @Override
     public String saveFile(@RequestBody FileDto fileDto) {
@@ -32,10 +42,13 @@
         //int saveFileFlag = fileServiceDaoImpl.saveFile(BeanConvertUtil.beanCovertMap(fileDto));
 
 
-        String fileName = FtpUpload.upload(fileDto.getContext(), java110Properties.getFtpServer(),
+        String fileName = ftpUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
                 java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
                 java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
 
+//        String fileName = jSchFtpUploadTemplate.upload(fileDto.getContext(), java110Properties.getFtpServer(),
+//                java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
+//                java110Properties.getFtpUserPassword(), java110Properties.getFtpPath());
         return fileName;
     }
 
@@ -49,11 +62,17 @@
             ftpPath += fileName.substring(0, fileName.lastIndexOf("/")+1);
             fileName = fileName.substring(fileName.lastIndexOf("/")+1, fileName.length());
         }
-        byte[] fileImg = FtpUpload.downFileByte(ftpPath, fileName, java110Properties.getFtpServer(),
+        byte[] fileImg = ftpUploadTemplate.downFileByte(ftpPath, fileName, java110Properties.getFtpServer(),
                 java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
                 java110Properties.getFtpUserPassword());
-
-        String context = new BASE64Encoder().encode(fileImg);
+        try {
+            OutputStream out = new FileOutputStream(new File("/home/hc/img/"+ UUID.randomUUID().toString()+".jpg"));
+            out.write(fileImg);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+       //String context = new BASE64Encoder().encode(fileImg);
+        String context = Base64Convert.byteToBase64(fileImg);
 
         fileDto.setContext(context);
         fileDtos.add(fileDto);

--
Gitblit v1.8.0