Solved

Show private files with a CGI application.

Posted on 2001-06-19
2
154 Views
Last Modified: 2010-04-04
I am looking for a solution to show files in private (not webserver public) directories on the web via a CGI executable. I tried it with a filestream it will work, but the browser can't recognize the filetype. For example:

c:\mywebserver\wwwroot is the location of my public files. I will give a user access to a file named: c:\test.pdf. The user have to call within it's browser my Delphi application getfile.exe:
http://mywebserver.com/cgi-bin/getfile.exe?file=c:\test.pdf&password=xxx
My application will load the file in a filestream and send the content of the filestream to the client. The data is OK. But IE don't understand that this is a pdf file and ask to download it and write it on disk with a strange name such as getfile.htm. If I choose to open it from the current location I will see the binary stream in my browser what I don't want.
0
Comment
Question by:snoei
2 Comments
 
LVL 8

Accepted Solution

by:
TOndrej earned 75 total points
ID: 6207434
I think you should set the content type to 'application/pdf'. See TCGIResponse.ContentType property.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6207482
This should work when the client has Acrobat Reader installed:


var fs: TFileStream;
begin
  fs := TFileStream.Create('pdffile.pdf', fmOpenRead);
  try
    Response.ContentType := 'application/pdf';
    Response.ContentStream := fs;
    Response.SendResponse;
  finally
    fs.Free;
  end;
end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now