From 7fbd9922fe6cbe98e63d9788796a2b16062c1ae0 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期三, 20 五月 2020 12:42:28 +0800
Subject: [PATCH] 加入时间后缀问题

---
 CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 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 e45b9b7..8ebdff8 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
@@ -7,13 +7,18 @@
 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 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 {
@@ -53,17 +58,23 @@
         List<FileDto> fileDtos = new ArrayList<>();
         String fileName = fileDto.getFileSaveName();
         String ftpPath = java110Properties.getFtpPath();
+        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
         if (fileName.contains("/")) {
-            ftpPath += fileName.substring(0, fileName.lastIndexOf("/")+1);
-            fileName = fileName.substring(fileName.lastIndexOf("/")+1, fileName.length());
+            ftpPath += fileName.substring(0, fileName.lastIndexOf("/") + 1);
+            fileName = fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length());
         }
-        byte[] fileImg = ftpUploadTemplate.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);
+//        String context = Base64Convert.byteToBase64(fileImg);
+        String context = ftpUploadTemplate.download(ftpPath, fileName, java110Properties.getFtpServer(),
                 java110Properties.getFtpPort(), java110Properties.getFtpUserName(),
                 java110Properties.getFtpUserPassword());
 
-        String context = new BASE64Encoder().encode(fileImg);
-
         fileDto.setContext(context);
+        fileDto.setSuffix(suffix);
         fileDtos.add(fileDto);
         return fileDtos;
     }

--
Gitblit v1.8.0