Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Indy TIdHTTPServer virtual files

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi there.
My goal is to make a Webserver which can handle virtual files. (Im using Indy's TIdHTTPServer).

This is the virtual filetable:
AF343BA23F - File1.zip
FBE323FBA2 - File2.zip
CFADE12167 - File3.zip

When the client asks for one of this three files (like this: it should be asked to save the file File1.zip. Instead, my webserver sends the filename AF343BA23F.zip to the client.

How do I change the filename I am sending to the client?

This is a Very simplified code example:
Code:
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
  LocalDoc: String;
  ByteSent: Cardinal;
begin
  if ARequestInfo.Document = '/AF343BA23F' then
    LocalDoc := 'C:\File1.zip'
  else if ARequestInfo.Document = '/FBE323FBA2' then
    LocalDoc := 'C:\File2.zip'
  else if ARequestInfo.Document = '/CFADE12167' then
    LocalDoc := 'C:\File3.zip';

  if FileExists(LocalDoc) then
    ByteSent := IdHTTPServer1.ServeFile(AThread, AResponseInfo, LocalDoc);
end;

The client is asked to save the file "AF343BA23F.zip". I want the client to be asked to save the file "File1.zip"


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"There is always another way to solve it, but I prefer my way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top