CGI to download file without URL display

Richard Herz herz at ucsd.edu
Wed Jul 10 15:52:01 EDT 2002


I would like to post files on a web page for download without any display of
the URL of the source file at the browser in order to prevent future bypass
of download logging.  The only method I've discovered so far that has no
display of the source file URL is to get the source file into a variable and
"put" it back to browser as "application/octet-stream":

#!mc
on startup
  # First log remote host address so if user bookmarks
  # this cgi file I at least log something, and/or
  # check for valid input from web form
  get url "binfile:../downloads/myApp.exe"
  put it into tBuffer
  put "Content-Type: application/octet-stream" & cr
  put "Content-Length:" && the length of tBuffer & cr & cr
  put tBuffer
end startup

Browser then asks if you want to open or save the file.  The cgi file name
must have the same name as the file to be downloaded (e.g., myApp.exe) in
order for the file to be saved with that name by the browser, so the file to
be downloaded can't be in the cgi-bin directory with the cgi script of the
same name.

QUESTIONS: Is MC's "put" as reliable as regular browser download of a URL?
Can I rely on the cgi host at a site provider to always be able to put a 1-3
MB file into RAM (i.e., is this a trivial amount of ram)?  Giving the CGI
file the same name as the download file is no problem in Linux but would it
be a problem on a Win server or on a Mac OS X server?

Doing a redirect with "Location:" or http-equiv="refresh" to the source file
flashes briefly the url of source file in browser status bar, might put url
in temp files, and might put url in Mac info comments.  If this method is
more reliable than the direct mc "put" above, I guess a shell script could
execute periodically to rename the source file directory.

Any other methods to use instead?

Thanks!
Rich Herz
herz at ucsd.edu
http://ReactorLab.net






More information about the metacard mailing list