A 3-Tier Download |
 |
The following 3-tier example downloads a file from
file server to Web server to browser. On the Web server, FileEE.AddDownloadFile
sets the file to download from the server and FileUpEE.SendRequest sends the
download request to the file server. On the file server,
FileUpEE.SendResponse sends the download to the Web server. After the file
arrives on the Web server, the FileEE.WriteToResponse downloads it to the browser.
Example
The example includes two scripts:
- Download.asp
Runs on the Web server. Download.asp requests the file
to download from the file server, receives the file, and sends it to
the browser.
- FileServer.asp
Runs on the File server. FileServer.asp gets the file
requested by Download.asp and sends it to the Web server.
Download.asp
Download.asp is on the Web server. This script requests a file from the file server,
receives the file, and sends it to the browser:
oFileUpEE.TargetURL = getTargetURL(False) & "/fileserver.asp"
Sets the page on the file server to which FileUpEE will submit the request.
Set oDownFile = oFileUpEE.AddDownloadFile(Server.MapPath(Application("sampleroot") &_
"/sample.doc"), "docdownload.doc")
Sets the file to get from the file server. AddDownloadFile takes
two arguments: the first is the path and name of the file on the file server, and
the second is a file name to use on the client - this name will be displayed in the
"Open or Save" dialog.
intSAResult = oFileUpEE.SendRequest()
Sends the download request to the file server. SendRequest returns an
SAResult value that allows you to check the status of the response from
the file server.
If intSAResult = saDownloaded Then
Response.ContentType = oDownFile.ContentType
This occurs after the Download.asp receives the response from the file server.
If the file arrived, the content-type response header is set, to ensure that the
browser handles the download correctly.
oDownFile.WriteToResponse Response
Sends the file from the Web server to the browser.
| To let the browser know how to handle a download, set the
content-type response header to the file's
ContentType
before sending the file to the browser.
|
FileServer.asp
FileServer.asp runs on the file server. It receives the download request from the Web
server and returns the requested file.
oFileUpEE.ProcessRequest Request, True, True
Passes the request from the Web server to FileUpEE.
Since AutoProcess (the third argument) is set
to True, FileUpEE will process the request automatically - that is,
execute the instructions set on the Web server.
oFileUpEE.SendResponse Response
Sends the response (in this case, downloads the file) to
the Web server.
Top
Copyright © 2003, SoftArtisans, Inc.