Hi Zopeople, I have some python files that I want users to be able to download. I would like them to be able to click on the anchor and start downloading. I must be missing something fundamental in Zope or HTML. I cannot figure out how to *download* the file instead of display it. I have tried creating a File object and DTML Document, tried changing the Content Type to application/msdownload (and about 20 other types). I have used DocFinder and tried all kind of method names (looking for the inverse of 'document_src'). Is there a way to force the download action instead of rendering? -- Jerry (Mailed safely with The Bat! 2.02.3 CE) ___________________________ Nobody can be un-cheered with a balloon.
We keep a list of dtml documents in a folder called 'Attachments' which we allow users to download by clicking on a link in a web page. Here is the code we use: <dtml-if "attachments"> <dtml-in "attachments.keys()" sort> <a class="stdlink" href="Attachments/<dtml-var sequence-item>"><dtml-var "attachments[_['sequence-item']]"></a><br> <dtml-else> none<br> </dtml-in> <dtml-else> none<br> </dtml-if> Note: 'attachments' in our case is a list variable containing the ids of the downloadable files. HTH Jonathan ----- Original Message ----- From: "Jerry" <lists411@myd1.com> To: "Zope" <zope@zope.org> Sent: February 12, 2004 7:04 PM Subject: [Zope] auto download link
Hi Zopeople,
I have some python files that I want users to be able to download. I would like them to be able to click on the anchor and start downloading. I must be missing something fundamental in Zope or HTML. I cannot figure out how to *download* the file instead of display it.
I have tried creating a File object and DTML Document, tried changing the Content Type to application/msdownload (and about 20 other types). I have used DocFinder and tried all kind of method names (looking for the inverse of 'document_src').
Is there a way to force the download action instead of rendering?
-- Jerry (Mailed safely with The Bat! 2.02.3 CE) ___________________________ Nobody can be un-cheered with a balloon.
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Jerry wrote at 2004-2-12 16:04 -0800:
I have some python files that I want users to be able to download. I would like them to be able to click on the anchor and start downloading. I must be missing something fundamental in Zope or HTML. I cannot figure out how to *download* the file instead of display it.
You must learn about the "Content-Disposition" header (search the mailing list archive). Come back when you have more questions. -- Dieter
Hi Dieter, You <DM> wrote on Friday (2/13/2004 at 11:21) thus about [Zope] auto download link: DM> Jerry wrote at 2004-2-12 16:04 -0800:
I have some python files that I want users to be able to download. I would like them to be able to click on the anchor and start downloading. I must be missing something fundamental in Zope or HTML. I cannot figure out how to *download* the file instead of display it.
DM> You must learn about the "Content-Disposition" header DM> (search the mailing list archive). DM> Come back when you have more questions. Blatantly disregarding your closing demand, I come bearing answers. ;) (Actually, your suggestion was helpful). After searching several archives I found THE ANSWER (that works for me(tm)). Either this is a well kept secret of the HTTP/1.1 gurus, or I'm just an ignorant snake. I set the Content Type of the File in the ZMI to ... application/save and now all the browsers that I've tested will automatically prompt to save the file with the correct name when one tries to open the URI. Other non-important details I found and/or learned: * The values placed into the Content-Type header are not specified in the HTTP/1.1 spec, and I couldn't find a definitive list. * I found the 'application/save' value in the Opera browser forum. * I tried Content-Disposition, and it worked for all browsers except Opera, where it added the .exe after the name I told it to save as. * Content-Disposition is not in the HTTP/1.1 specifications, but comes from e-mail headers and is 'suggested' for browsers to obey. * searching Google for "application/save" doesn't work (/=white space) * searching Google for header "content-type" "application/save" gets only 14 mentions of application/save, all in PHP forums * searching Google using http://www.google.com/intl/xx-elmer/ is more fun. * I hope somebody in the future finds this and saves themselves hours of searching! -- Jerry (Mailed safely with The Bat! 2.02.3 CE) ___________________________ Everything comes to him who hustles while he waits. -- Thomas A. Edison
Hi Jerry, Jerry wrote:
Hi Dieter,
You <DM> wrote on Friday (2/13/2004 at 11:21) thus about [Zope] auto download link: DM> Jerry wrote at 2004-2-12 16:04 -0800:
I have some python files that I want users to be able to download. I would like them to be able to click on the anchor and start downloading. I must be missing something fundamental in Zope or HTML. I cannot figure out how to *download* the file instead of display it.
DM> You must learn about the "Content-Disposition" header DM> (search the mailing list archive). DM> Come back when you have more questions.
Blatantly disregarding your closing demand, I come bearing answers. ;) (Actually, your suggestion was helpful).
After searching several archives I found THE ANSWER (that works for me(tm)). Either this is a well kept secret of the HTTP/1.1 gurus, or I'm just an ignorant snake. I set the Content Type of the File in the ZMI to ...
application/save
and now all the browsers that I've tested will automatically prompt to save the file with the correct name when one tries to open the URI.
This is just because application/save is usually not linked to any application. The standard (as of mime) compliant way to specify a not linked mime-type is application/octed-stream. content-disposition helps to specify an intended filename which is often respected by browsers. With File-objects in zope you can for example call a script to modify response-headers as "precondition". HTH Tino Wildenhain
application/save
This is just because application/save is usually not linked to any application.
I usually use a modified Content-dispostion header to make the browser save the file, and it works in all browsers I have tested (not many). Just specify "attachment", like this: Content-type: text/plain Content-disposition: filename.txt; attachment JZ
participants (5)
-
Dieter Maurer -
Jerry -
John Ziniti -
Small Business Services -
Tino Wildenhain