• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Client side download from FTP Server (FTPClient from Apache)

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

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..

Is there a way I can do this?
 
Rancher
Posts: 1337
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is there a way I can do this?


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:[email protected]/directory/TextFile" (check the appropriate RFC for how exactly an FTP URL looks).
 
Vinvin Parpar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Thanks!
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Vinvin Parpar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic