java110
2020-05-20 7fbd9922fe6cbe98e63d9788796a2b16062c1ae0
CommonService/src/main/java/com/java110/common/smo/impl/FileInnerServiceSMOImpl.java
@@ -13,8 +13,12 @@
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 {
@@ -54,18 +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);
        String context = Base64Convert.byteToBase64(fileImg);
        fileDto.setContext(context);
        fileDto.setSuffix(suffix);
        fileDtos.add(fileDto);
        return fileDtos;
    }