You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by wc184 <md...@hotmail.com> on 2007/03/07 00:44:58 UTC
File Upload/Download
Hi,
I'm trying to implement a file download/upload feature in my application.
The file is stored in a db2 blob. I'm currently using the
org.apache.cocoon.servlet.multipart.Part class to extract the file from the
request. This is my pipeline in sitemap to process download requests
<map:match pattern="dlchs*-_-*.xml">
<map:read type="databasereader" src="{2}" >
<map:parameter name="table" value="DB.REQUESTDOCUMENTS"/>
<map:parameter name="image" value="document"/>
<map:parameter name="key" value="documentid"/>
<map:parameter name="type-column" value="contenttype"/>
</map:read>
The problem I have is the URL has to match "dlchs*-_-*.xml". This,
subsequently, prompts the user to save the file under this format by
default. I would IE to prompt the user to save under the original filename.
Do you know any alternative method for downloading files?
Thank you.
WC
</map:match>
--
View this message in context: http://www.nabble.com/File-Upload-Download-tf3359151.html#a9343806
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: File Upload/Download
Posted by "Steven D. Majewski" <sd...@virginia.edu>.
On Mar 6, 2007, at 7:41 PM, Mark Lundquist wrote:
> Hi,
>
> On Mar 6, 2007, at 3:44 PM, wc184 wrote:
>
>> The problem I have is the URL has to match "dlchs*-_-*.xml". This,
>> subsequently, prompts the user to save the file under this format by
>> default. I would IE to prompt the user to save under the original
>> filename.
>
> I think you need these response headers:
>
> Cache-Control: Pragma:no-cache
> Content-Disposition: attachment; filename=what.ever
>
> You can use the HTTPHeaderAction within your pipeline to set those
> from the sitemap.
>
I posted a similar question recently:
http://www.mail-archive.com/users@cocoon.apache.org/msg37572.html
Other messages in an earlier thread seemed to indicate that
setting the header with an action for a file served by a cocoon reader
did not work:
http://www.mail-archive.com/users@cocoon.apache.org/msg35877.html
http://www.mail-archive.com/users@cocoon.apache.org/msg35879.html
And another message somewhere seemed to say there was a similar problem
with doing it from flowscript.
I noted in another message the correction that it did in fact work for
me using flowscript to set the headers before calling the pipeline
using the reader:
http://www.mail-archive.com/users@cocoon.apache.org/msg37586.html
function download() {
var uri = cocoon.request.getParameter( 'uri' );
var filename = uri.substr( uri.lastIndexOf( '/' ) + 1 );
cocoon.response.addHeader( 'Content-disposition', 'attachment ;
filename=' + filename );
cocoon.sendPage( uri, {} );
cocoon.exit();
}
And, in fact, I just tried Mark's simpler solution with an
HttpHeaderAction,
and that simpler solution also works ( despite those messages in the
mail-list archive suggesting
that both do not work! )
<map:match pattern="*/*.xml">
<map:act type="set-header">
<map:parameter name="Cache-Control" value="Pragma:no-
cache" />
<map:parameter name="Content-Disposition"
value="attachment ; filename={2}.xml" />
</map:act>
<map:read src="published/{1}/{2}.xml" mime-type="text/xml" />
</map:match>
I guess the lesson here is that reports that something does work are
probably more reliable
than reports that something doesn't work: there can be all sorts of
other reasons something
doesn't work than the reason inferred by the original posters.
-- Steve Majewski / UVA Alderman Library
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [was: Stripping down Cocoon] File Upload/Download
Posted by wc184 <md...@hotmail.com>.
Thanks for you reply, Mark.
I found this on the Cocoon Wiki:
http://wiki.apache.org/cocoon/DownloadFilesToLocalDisk?highlight=%28download%29
I'm pretty new to Cocoon. I'm not sure how to declare the header. What else
do I need to configure other than setting the pipline in the sitemap file?
Any pointers? Thanks.
WC
Mark Lundquist-3 wrote:
>
> Hi,
>
> On Mar 6, 2007, at 3:44 PM, wc184 wrote:
>
>> The problem I have is the URL has to match "dlchs*-_-*.xml". This,
>> subsequently, prompts the user to save the file under this format by
>> default. I would IE to prompt the user to save under the original
>> filename.
>
> I think you need these response headers:
>
> Cache-Control: Pragma:no-cache
> Content-Disposition: attachment; filename=what.ever
>
> You can use the HTTPHeaderAction within your pipeline to set those from
> the sitemap.
>
> HTH,
> —ml—
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/File-Upload-Download-tf3359151.html#a9355710
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: File Upload/Download
Posted by Mark Lundquist <lu...@gmail.com>.
Hi,
On Mar 6, 2007, at 3:44 PM, wc184 wrote:
> The problem I have is the URL has to match "dlchs*-_-*.xml". This,
> subsequently, prompts the user to save the file under this format by
> default. I would IE to prompt the user to save under the original
> filename.
I think you need these response headers:
Cache-Control: Pragma:no-cache
Content-Disposition: attachment; filename=what.ever
You can use the HTTPHeaderAction within your pipeline to set those from
the sitemap.
HTH,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org