I have a question regarding Apache's FTPClient.retrieveFile(), here's the situation, I've created a simple web application and I was planning on letting the users download files from a FTP Server whenever the user clicks a button or link on my web page. I found a library from Apache that contains FTP manipulations, and I want to use it as the method of downloading files from the FTP Server into the local drive of the user.
How will I achieve this?
I've tried to using retrieveFile() but it only downloads the files from the FTP Server into the Application Server not to the local drive (Client Side) of the user..
Not unless there's an applet or JavaWebStart application on the client that can run this code. But for a simple file download via FTP this isn't necessary, since browsers have FTP built in. If memory serves, the URL syntax would be something like "ftp://user:firstname.lastname@example.org/directory/TextFile" (check the appropriate RFC for how exactly an FTP URL looks).
Joined: Sep 16, 2010
You're right Lester, I tried it and it works, I used a hotlink on my page and whenever the user clicks on it the page displays the contents of the file.
How can I automate the download of file without displaying the contents of it on the web page? If this is not achievable I'll have to stick with the client side jar to invoke the download.
Joined: Oct 14, 2008
If the file has a filename extension (like .txt, .pdf etc.), then the browser mechanism for dealing with downloads should kick in. In other words, it would be up to the user to configure their browser to display or save the file. Not sure how browser handle files that have no extension.
Joined: Sep 16, 2010
Yeah, so basically it all depends on my browser whether or not I have TXT/PDF reading plugins / capabilities..
I tried the same code on a different file type (jar, zip), it shows a save prompt.
Thanks for the answer Lester it really gave me an idea on how to solve this.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Client side download from FTP Server (FTPClient from Apache)