Date: 2004-04-16T04:53:44
Editor: 195.134.212.189 <>
Wiki: Cocoon Wiki
Page: DownloadFilesToLocalDisk
URL: http://wiki.apache.org/cocoon/DownloadFilesToLocalDisk
no comment
Change Log:
------------------------------------------------------------------------------
@@ -1,66 +1,65 @@
-Here is an example to download files to a local directory with Cocoon 2.1
Final release.
-To be more specific, I'll show you how to pop up a downloading box instead of
displaying a document into the browser.
-
-I've tried two different methods. There is no need to configure Cocoon
particularly. All is made in the sitemap.
-
-
-
- * Using a Reader.
-{{{
-<map:pipeline>
- <map:match pattern="save/*">
- <map:act type="header">
- <map:parameter name="Cache-Control" value="Pragma:no-cache" />
- <map:parameter name="Content-Disposition" value="attachment ;
filename={1}.xml" />
- </map:act>
- <map:read type="resource" mime-type="binary/octet-stream" src="{1}.xml">
- <map:parameter name="format" value="xml"/>
- </map:read>
- </map:match>
-</map:pipeline>
-}}}
-
-I this pipeline, you are no need to create custom sitemap components. link
-
- *First you have to modify the header to set the Response object.
-To do that, use the HttpHeaderAction (don't forget to declare it).
-Let's see the different options :
-
-'''"Cache-Control"''' is used to tell not to use the cache.
-
-'''"Content-disposition"''' is used to define the document as an attachment
and to specify a filename. You can set any name you want with any extension.
-
-
- *Secondly, you have to specify the mime-type of the reader. Set it to
"binary/octet-stream".
-I'm not sure parameter "format" as an influence.
-
-
-
- * Using a Serializer and an Action
-{{{
-<map:pipeline>
- <map:match pattern="save/*">
- <map:generate type="GetDocument" src="{1}.xml" />
- <map:act type="header">
- <map:parameter name="Cache-Control" value="Pragma:no-cache" />
- <map:parameter name="Content-Disposition" value="attachment ;
filename={1}.xml" />
- <map:parameter name="mime-type" value="binary/octet-stream" />
- </map:act>
- <map:serialize type="file" mime-type="binary/octet-stream" />
- </map:match>
-</map:pipeline>
-}}}
-
-
-
- *First, you set the Response object with an action (include in Cocoon
classes).
- *Secondly, you have to specify the mime-type of the serializer.
-
-This works with IE, mozilla and firebird.
-Be careful to remove your cache and to reload your browser. If it's not
working reopen you're browser.
-
-
-Lionel Crine
-[[BR]]
-[[BR]]
-'''Attachment:''' attachment:cocoon+chapter6.pdf [[BR]]
+Here is an example to download files to a local directory with Cocoon 2.1
Final release.
+To be more specific, I'll show you how to pop up a downloading box instead of
displaying a document into the browser.
+
+I've tried two different methods. There is no need to configure Cocoon
particularly. All is made in the sitemap.
+
+
+
+ * Using a Reader.
+{{{
+<map:pipeline>
+ <map:match pattern="save/*">
+ <map:act type="header">
+ <map:parameter name="Cache-Control" value="Pragma:no-cache" />
+ <map:parameter name="Content-Disposition" value="attachment ;
filename={1}.xml" />
+ </map:act>
+ <map:read type="resource" mime-type="binary/octet-stream" src="{1}.xml">
+ <map:parameter name="format" value="xml"/>
+ </map:read>
+ </map:match>
+</map:pipeline>
+}}}
+
+I this pipeline, you are no need to create custom sitemap components. link
+
+ *First you have to modify the header to set the Response object.
+To do that, use the HttpHeaderAction (don't forget to declare it).
+Let's see the different options :
+
+'''"Cache-Control"''' is used to tell not to use the cache.
+
+'''"Content-disposition"''' is used to define the document as an attachment
and to specify a filename. You can set any name you want with any extension.
+
+
+ *Secondly, you have to specify the mime-type of the reader. Set it to
"binary/octet-stream".
+I'm not sure parameter "format" as an influence.
+
+
+
+ * Using a Serializer and an Action
+{{{
+<map:pipeline>
+ <map:match pattern="save/*">
+ <map:generate type="file" src="{1}.xml" />
+ <map:act type="header">
+ <map:parameter name="Cache-Control" value="Pragma:no-cache" />
+ <map:parameter name="Content-Disposition" value="attachment ;
filename={1}.xml" />
+ </map:act>
+ <map:serialize type="xml" />
+ </map:match>
+</map:pipeline>
+}}}
+
+
+ *Generate a file.
+ *Set the Response object with the action HttpHeaderAction (included in
Cocoon).
+ *Serialize the flow
+
+This works with IE, mozilla and firebird.
+Be careful to remove your cache and to reload your browser. If it's not
working reopen you're browser.
+
+
+Lionel Crine
+[[BR]]
+[[BR]]
+'''Attachment:''' attachment:cocoon+chapter6.pdf [[BR]]