Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Using Content-Disposition Header

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


mutant.nzatgmail.com

Aug 30, 2005, 7:14 PM

Post #1 of 3 (164 views)
Permalink
Using Content-Disposition Header

Hi,

Is there any way to use the 'Content-Disposition' header with Catalyst to
prompt the user to download a file?

Using the Apache module, I'd simply set up the header, open the file, and
print the contents to STDOUT.

Under Catalyst doing this, or setting $c->res->body() to the contents causes
the file to get corrupted (because it's treating it as text?)

Any help would be appreciated.

Thanks,
Sam.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst/attachments/20050830/ffbd38f8/attachment.htm


tshinnicatio.com

Aug 30, 2005, 8:26 PM

Post #2 of 3 (146 views)
Permalink
Using Content-Disposition Header [In reply to]

At 12:18 8/30/2005, Mutant wrote:
>Hi,
>
>Is there any way to use the 'Content-Disposition' header with Catalyst to prompt the user to download a file?
>
>Using the Apache module, I'd simply set up the header, open the file, and print the contents to STDOUT.
>
>Under Catalyst doing this, or setting $c->res->body() to the contents causes the file to get corrupted (because it's treating it as text?)
>
>Any help would be appreciated.

Others will no doubt know better, but this from my notes:

Use the 'attachment' keyword on content-disposition to hint to the browser that this file should not be displayed but rather saved:
Content-Disposition: attachment; filename="Culver_OL_2.LAS"

Use the 'name' on the content-type as yet another way (in addition to the above) to suggest what the saved filename should default to:
Content-Type: application/octet-stream; name="Culver_OL_2.LAS"

Of course the actual mime type _should_ be accurate, like "application/pdf", but using "application/octet-stream" is supposed to help the browser decided to save as a file rather than try to display.

>Thanks,
>Sam.


Danijel.Milicevicatrawmode.org

Aug 30, 2005, 8:51 PM

Post #3 of 3 (147 views)
Permalink
Using Content-Disposition Header [In reply to]

Am Dienstag, den 30.08.2005, 13:29 -0500 schrieb Thomas L. Shinnick:
> Others will no doubt know better, but this from my notes:
>
> Use the 'attachment' keyword on content-disposition to hint to the browser that this file should not be displayed but rather saved:
> Content-Disposition: attachment; filename="Culver_OL_2.LAS"
>
> Use the 'name' on the content-type as yet another way (in addition to the above) to suggest what the saved filename should default to:
> Content-Type: application/octet-stream; name="Culver_OL_2.LAS"
>
> Of course the actual mime type _should_ be accurate, like "application/pdf", but using "application/octet-stream" is supposed to help the browser decided to save as a file rather than try to display.

Exactly, in Catalyst code this is for example:
$c->res->headers->header( "Content-type" => 'text/csv');
$c->res->headers->header( "Content-Disposition" => 'attachment;
filename=export.csv');

Regards,
Danijel Milicevic

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.