I have a requirement to download a image from FTP server to android device. I tried with few samples by using ftp4j-1.7.2.jar
library, but failed to connect with FTP servers & messed up.
Have anyone worked with FTP servers?
Please suggest to make connection & download file from Server.
Android Use FTP 1 Download a Third-party FTP App. As mentioned above, you need to have an FTP app on your Android. Some file explorers such as ES File ... 2 Connect to the Same Wi-Fi Network. 3 Start FTP Service. 4 Open the FTP Link on Your PC. See More....
Upload Files Using FTP 1 Connect to FTP Server via Command Line. To connect to any FTP server from windows open its command prompt and for Linux open terminal window ... 2 Upload Single File to FTP Server. 3 Download A Single File from FTP. 4 Upload Multiple Files to FTP. 5 Download Multiple Files from FTP. See More....
You can only download your Android files to PC. To access files from the Chrome, enter the FTP URL in the address bar of Chrome and press enter. To perform actions like upload, move or rename, you can use the File Explorer on your PC or download an FTP application like FileZilla.
One of my recent tasks has been to download a file from an FTP server. The recommended solution is to use the Apache Commons Net library for that, which supports FTP among many others protocols. Adding it to the project was as easy as putting the jar into the libs/ directory.
Use library commons.apache.org/proper/commons-net
Check below code to download file from FTP server:
private Boolean downloadAndSaveFile(String server, int portNumber,
String user, String password, String filename, File localFile)
throws IOException {
FTPClient ftp = null;
try {
ftp = new FTPClient();
ftp.connect(server, portNumber);
Log.d(LOG_TAG, "Connected. Reply: " + ftp.getReplyString());
ftp.login(user, password);
Log.d(LOG_TAG, "Logged in");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
Log.d(LOG_TAG, "Downloading");
ftp.enterLocalPassiveMode();
OutputStream outputStream = null;
boolean success = false;
try {
outputStream = new BufferedOutputStream(new FileOutputStream(
localFile));
success = ftp.retrieveFile(filename, outputStream);
} finally {
if (outputStream != null) {
outputStream.close();
}
}
return success;
} finally {
if (ftp != null) {
ftp.logout();
ftp.disconnect();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With