| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | } |
| | | ftpClient.login(userName, userPassword); |
| | | ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); |
| | | ftpClient.enterLocalPassiveMode(); |
| | | int reply = ftpClient.getReplyCode(); |
| | | if (!FTPReply.isPositiveCompletion(reply)) { |
| | | ftpClient.disconnect(); |
| | |
| | | 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; |