java110
2020-05-18 ae7e70bd01c207d6aac8e8ca6b6c3221c87c395e
java110-core/src/main/java/com/java110/core/client/FtpUploadTemplate.java
@@ -2,6 +2,7 @@
import com.java110.utils.util.Base64Convert;
import com.java110.utils.util.DateUtil;
import com.tencentcloudapi.tci.v20190318.models.FaceExpressionResult;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
@@ -209,6 +210,14 @@
        return return_arraybyte;
    }
    public static void main(String[] args) {
        FtpUploadTemplate ftpUploadTemplate = new FtpUploadTemplate();
        String img = ftpUploadTemplate.download("/hc/img/20200518/","ed05abae-2eca-40ff-81a8-b586ff2e6a36.jpg",
                "118.89.243.11",617,"hcdemo","45j74jpWTf7bNhnC");
        System.out.printf("img="+img);
    }
    public String download(String remotePath, String fileName, String server, int port, String userName, String userPassword) {
        InputStream is = null;
        ByteArrayOutputStream bos = null;
@@ -219,6 +228,7 @@
            }
            ftpClient.login(userName, userPassword);
            ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
            ftpClient.enterLocalPassiveMode();
            int reply = ftpClient.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftpClient.disconnect();
@@ -228,7 +238,7 @@
                    FTP.DEFAULT_CONTROL_ENCODING);
            is = ftpClient.retrieveFileStream(f);// 获取远程ftp上指定文件的InputStream
            if (null == is) {
                throw new FileNotFoundException(f);
                throw new FileNotFoundException(remotePath);
            }
            bos = new ByteArrayOutputStream();
            int length;