Hi again everyone...
So, I've unsubscribed the old address that's still having problems,
and resubscribed with a new one that works...
Back to my little exercise. I've combined Ian's and Terrel's hints into
something that (sort of) does the job :
Send the headers with self._response.setHeader() :
Content-type: application/octet-stream
Content-Disposition: attachment;filename=foo.bar
then read/write the file :
f = open('foo.bar')
self.write(f.read())
f.close()
(this was the actual missing link - I was naively hoping that things
would automagically happen by sending the headers :)
This gets me a download dialog in the browser, and actually
downloads the file.
Now there are two mysteries left :
1) the file downloaded by the browser is not the original content. It
has additional HTML tags added at the start and at the end (like the
skeleton of an empty HTML template). I didn't see it right away as
this doesn't bother JPEG or ZIP viewers, but downloaded EXE apps
don't run anymore. Where do these come from ?...
2) Now I understand Ian's previous remark :
"I'm not sure how you'd download several files at a time, but doing
one file is fairly easy -- if you want, you could zip several files and
download the zip file to the user."
If I loop the above code over a list of files, I get only one download
dialog in the browser (for the first file), and the downloaded file is
the concatenation of all the source files... I've tried clearing the
headers before sending each file, but that's probably not that
function's function :)
Is there any way around this ?
Oh, and a final question : it looks like the Webkit server reads the
entire file in memory before it starts the download. If so, this can
become a problem with large files... Would "chunking" the file
read/write (as in the "shutil" module) be enough to avoid that ?
TIA (& sorry for the pestering :)
fp
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss