tags:

views:

28

answers:

2

I have a need to push out a file package that includes a driver via my website for download. The only issue is it cannot be transferred in ASCII mode or else it becomes corrupt. I've looked at alternatives for FTP download but would rather not have an application that is created that can be downloaded just to transfer files. I'm looking into the possibility of creating an ASP.NET page that will use FTP for the download process.

I've seen a few examples but I also have a few questions:

  1. How best to protect the login/password information instead of putting it in code? Can that be referenced from web.config?
  2. Any possibility of showing download progress? Is AJAX my only option?
  3. Ability to allow the user to select a download location on their local machine?

EDIT Could I add a MIME type for ZIP and EXE files of application/octet-stream that would force a Binary download of the files?

A: 

Why FTP? You could create an HTTP Handler to push down the binaries. Here is more information on HTTP Handlers: http://www.15seconds.com/issue/020417.htm

Josh
Thanks for the pointer - I'll review it and see what I find.
Jeff
Can you expand on your thoughts of using the HTTP Handler to "push down the binaries". How does this fix my issue of ASCII vs BINARY transfer?
Jeff
Sorry for the delay getting back to you. With the Handler you can push either text or Binary.
Josh
A: 

You can use the WebClient class.

using (WebClient ftpClient = new WebClient())
{
    ftpClient.DownloadFile("ftp://domain.org/file.txt", "file.txt");
}

For authenticated requests

using (WebClient ftpClient = new WebClient())
{
    ftpClient.DownloadFile("ftp://user:[email protected]/file.txt", "file.txt");
}
jojaba
You can also use WebClient.OpenRead() and Response.OutputStream to tunnel the FTP data through HTTP.
jojaba