At 09:17 AM 8/15/2001 -0400, Clark C . Evans wrote:
>This is probably a trivial question, but
>how do I serve up a file from the filesystem
>programmatically? I use a query parameter
>to extract a given file from PostgreSQL
>database into a temp directory... and now
>I need to serve the file to the client
>(with the appropriate MIME type) ... after
>the file is served, I can then delete the
>temp file. Is there an easy way to do this?
Does the data *have* to go to a file? e.g., are you writing it via your
application, or is the Postgres server doing so? If Postgres is not, you
could do something like:
response = self.response()
data = self.fetchData()
and skip the whole file business. Otherwise, you can follow Ian's
suggestion, throwing in the setHeader() above.
>Also, I was wondering if anyone knows how to
>get IE explorer to "download" a MS Word document
>instead of opening it up "in-place"? I
>was thinking of setting the MIME type to
>something random (x-unknown\2001081509242232)
>and then hope that IE doesn't bother to look
>at the file extension... thoughts?
Don't know. You'll have to try out your idea and Ian's and let us know.
Well, you could also consider delivering a .zip or .tar file assuming the
end user has something like WinZip and doesn't mind the extra step.
Also, I think the user can configure IE to always open, always download or
always ask. Perhaps the real solution is to provide your users with that
pointer and leave it to their preference, instead of trying to force it and