Script to simulate file downloading

This is a discussion on Script to simulate file downloading within the Linux Web Servers forums, part of the Web Server and Related Forums category; I'm putting together a custom document management system. (Don't ask why I don't use one of the ...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-30-2007
Patrick Nolan
 
Posts: n/a
Default Script to simulate file downloading

I'm putting together a custom document management system.
(Don't ask why I don't use one of the many open-source systems.)
I'm trying to find a clean way to deal with different file types
and versions. Users can upload files of any type (Word, Power Point,
Open Office, PDF, ...) and I have to keep track of the versions.
I came up with a scheme in which I store the documents with
new file names produced from a unique document ID and version,
for instance "112-1". I save the original uploaded file name in
a database for future use.

When someone downloads a file, I want the resulting file to have
the original name, for instance "foobar.doc" instead of "112-1".
My guess is that it should be possible to accomplish this by
manipulation of the http headers, but I haven't figured it out yet.
I have written a perl script that sends headers like this:
Content-type: application/octet-stream
Title: foobar.doc
Content-Length: 26450

and then sends the content of the file. It arrives and is readable,
but the name of the file produced is the name of the script, not
foobar.doc.

Is this approach going to work if I find the right incantation?
(I haven't found a good description of what headers are sent when
you a browser asks to download a file.) I could probably think of
something else, such as making a temporary copy of the file on the
server with the correct name.

If I really wanted to get fancy, I could probably learn about MIME
types and tweak the Content-type header too. Agh!
  #2 (permalink)  
Old 08-30-2007
phantom
 
Posts: n/a
Default Re: Script to simulate file downloading

"Patrick Nolan" <pln@glast2.Stanford.EDU> wrote in message
news:slrnfdc6fb.v46.pln@glast2.Stanford.EDU...
> When someone downloads a file, I want the resulting file to have
> the original name, for instance "foobar.doc" instead of "112-1".
> My guess is that it should be possible to accomplish this by
> manipulation of the http headers, but I haven't figured it out yet.
> I have written a perl script that sends headers like this:
> Content-type: application/octet-stream
> Title: foobar.doc
> Content-Length: 26450
>
> and then sends the content of the file. It arrives and is readable,
> but the name of the file produced is the name of the script, not
> foobar.doc.
>

This header should be the one you are after -
Content-Disposition: attachment;filename="foobar.doc"



 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:35 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0