apache-commons-net

Download entire FTP directory in Java (Apache Net Commons)

帅比萌擦擦* 提交于 2019-12-01 11:20:14
I am trying to recursively iterate through the entire root directory that I arrive at after login to the FTP server. I am able to connect, all I really want to do from there is recurse through the entire structure and and download each file and folder and have it in the same structure as it is on the FTP. What I have so far is a working download method, it goes to the server and gets my entire structure of files, which is brilliant, except it fails on the first attempt, then works the second time around. The error I get is as follows: java.io.FileNotFoundException: output-directory\test

Upload file via Ant FTP task in Maven

我与影子孤独终老i 提交于 2019-12-01 05:30:51
I'm trying to upload a file using an Ant task. If I use Ant directly the file is uploaded, but if I call the ant task via Maven (using the maven-antrun-plugin ) I get the following error: An Ant BuildException has occured: The following error occurred while executing this line: /home/me/proj/build.xml:15: Problem: failed to create task or type ftp Cause: the class org.apache.tools.ant.taskdefs.optional.net.FTP was not found. This looks like one of Ant's optional components. Action: Check that the appropriate optional JAR exists in -ANT_HOME/lib ant-commonsnet.jar is clearly available to Ant: $

Java FTPS fails to retrieve file list (FileZilla Client works fine)

时光怂恿深爱的人放手 提交于 2019-12-01 01:49:29
I am using Apache Commons Net (v3.5) with a Java 8 to connect to a remote FTPS site (i.e. out on the internet). I am able to easily connect with a FileZilla client on my Windows 10 machine, but my Java program is unable to complete the same steps. I've googled high and low, but cannot find the root cause. Here are things that I have confirmed: I ensured the Java FTP commands are in the exact same order as the FileZilla client. I disabled Windows Firewall and Anti-Virus on the PC I re-enabled Windows Firewall and enabled logging. When using FileZilla, the Windows Firewall Log lists the TCP

Java FTPS fails to retrieve file list (FileZilla Client works fine)

蓝咒 提交于 2019-11-30 21:06:52
问题 I am using Apache Commons Net (v3.5) with a Java 8 to connect to a remote FTPS site (i.e. out on the internet). I am able to easily connect with a FileZilla client on my Windows 10 machine, but my Java program is unable to complete the same steps. I've googled high and low, but cannot find the root cause. Here are things that I have confirmed: I ensured the Java FTP commands are in the exact same order as the FileZilla client. I disabled Windows Firewall and Anti-Virus on the PC I re-enabled

Calculate file checksum in FTP server using Apache FtpClient

£可爱£侵袭症+ 提交于 2019-11-30 18:00:43
问题 I am using FtpClient of Apache Commons Net to upload videos to FTP server. To check if the file has really been successfully transferred, I want to calculate the checksum of remote file, but unfortunately I found there is no related API I could use. My question is: Whether there is a need to calculate file checksum in ftp server? If the answer is yes, how to get checksum in FtpClient? If the answer is no, how do FtpClient know if the file has really been successfully and completely

Apache Commons FTPClient Hanging

耗尽温柔 提交于 2019-11-30 04:50:34
We are using the following Apache Commons Net FTP code to connect to an FTP server, poll some directories for files, and if files are found, to retrieve them to the local machine: try { logger.trace("Attempting to connect to server..."); // Connect to server FTPClient ftpClient = new FTPClient(); ftpClient.setConnectTimeout(20000); ftpClient.connect("my-server-host-name"); ftpClient.login("myUser", "myPswd"); ftpClient.changeWorkingDirectory("/loadables/"); // Check for failed connection if(!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) { ftpClient.disconnect(); throw new

Uploading a file to a FTP server from android phone?

橙三吉。 提交于 2019-11-30 03:59:05
Following is the code that's suppose to create a text document and upload it to my FTP server. For some reason it doesn't seem to work. I used to the libraries provided at http://lavalatwork.blogspot.tw/2010/09/using-apache-commons-ftp-library-in.html for communicating with the FTP server. try { final String testString = new String("Hello"); FileOutputStream fOut = openFileOutput("samplefile.txt", MODE_WORLD_READABLE); OutputStreamWriter osw = new OutputStreamWriter(fOut); osw.write(testString); osw.flush(); osw.close(); } catch(IOException ex) { } FTPClient mFTP = new FTPClient(); try { //

Is there a way to tell if the FTP server is active or passive in the Java web program?

烂漫一生 提交于 2019-11-29 12:35:40
I'm using the Apache-Commons-Net library. I want to know if the FTP server is active-mode or passive-mode. Is there a method like that in the Apache-Commons-Net library? ( GetDataConnectionMode() is a method that tells you the connected mode after connecting in Java. I want to check Maud before) private FTPClient ftp; // the code I want if(active){ ftp.enterLocalActiveMode(); }else{ ftp.enterLocalPassiveMode(); } // Apply active mode or passive mode to the environment of the server for oneself As @Erwin already commented, servers are not in active or passive mode. Servers usually support both

Apache Commons FTP problems

半城伤御伤魂 提交于 2019-11-29 10:59:21
I want to implement a FTP Client with Apache Commons Net only for uploading data. The Connection and Login to FTP-Server works fine. But the upload does not work right. The files are a little to big as the originals. And the files are damaged. I tried an image, a video and a textfile. Only the textfile is alright. Now I see while debugging boolean tmp=client.setFileTransferMode(FTPClient.BINARY_FILE_TYPE); gives me false . So it can not be set. Why? (Maybe this is not the problem?) Here a the rest of my code client=new FTPClient(); try { int reply; client.connect(url, port); reply = client

How do I configure client authentication with generated certificate in apache-commons net

 ̄綄美尐妖づ 提交于 2019-11-29 08:46:05
First off, I know there is a similar question here but it doesn't answer my doubts. I have a FTPS server (vsftpd) configured with SSL. I've generated the appropriate keys with: openssl req -x509 -nodes -days 1825 -newkey rsa:2048 \ -keyout private/vsftpd.key \ -out certs/vsftpd.crt And configured the respective conf file in the server. Now, in the Java client code with Apache commons net, I'm able to communicate with the server over SSL with something like this: import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; import org.apache.commons.net