You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexander Cherednichenko <le...@gmail.com> on 2011/12/15 22:54:13 UTC

Asking for download files with non-ascii names.

Hello!

Faced an interesting problem, however few hours of googling and trial did
not lead to success. wicket is 1.4

The problem: I have an AjaxDownload (
https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html)
or DownloadLink (
http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/link/DownloadLink.html),
both very good and cool components. Thank you the developers! I am
streaming a dynamically-generated content to the user and want them to save
it as a file. Usual implementation of both is coming down
to ResourceStreamRequestTarget, which in turn does the actual streaming and
also sets the content-disposition: attachment; filename=''.

And here the trouble starts. If we have, say, cyrillic names of the files
to present to user, they are displayed incorrectly in browser. ASCII is
okay, but as soon as it comes down to non-english, encoding is broken.
That's a good article describing problem in general -
http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http
(it
is a problem of browsers, and not Wicket). The good solution seen there is
to add content-disposition header without a filename, and make download
happen off the URL which is ending in the desired filename.

Now, the question - how do i do it in wicket? Say, I have an AjaxLink
within page, which has an AjaxDownload attached to it. AjaxDownload is an
anonymous inner class and is using some page's model to generate its data.
The callback URL of this behavior is standard and is starting with ?, e.g.
I can not add /filename.ext prior to it, it would break wicket's request
target location with 404 as a result.

The only idea I have at the moment is to mount the page with a Hybrid
coding strategy, thus the filename would then be considered just as one of
the parameters by the page, but the solution seems to be a little smelly.

Did anyone face the same problem?

Great thanks and appreciation in advance!

with kindest regards,

-- 
Alexander Cherednichenko
[ the only way out is the way up ]

Re: Asking for download files with non-ascii names.

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

In my app we use Wicket's Resource to upload/download files. We do it
to avoid synchronization on page access but I think you can solve your
problem with this.

Unfortunately I imagine the full solution with Wicket 1.5's
#mountResource(). See
http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/ for
more details.

On Thu, Dec 15, 2011 at 11:54 PM, Alexander Cherednichenko
<le...@gmail.com> wrote:
> Hello!
>
> Faced an interesting problem, however few hours of googling and trial did
> not lead to success. wicket is 1.4
>
> The problem: I have an AjaxDownload (
> https://cwiki.apache.org/WICKET/ajax-update-and-file-download-in-one-blow.html)
> or DownloadLink (
> http://wicket.apache.org/apidocs/1.4/org/apache/wicket/markup/html/link/DownloadLink.html),
> both very good and cool components. Thank you the developers! I am
> streaming a dynamically-generated content to the user and want them to save
> it as a file. Usual implementation of both is coming down
> to ResourceStreamRequestTarget, which in turn does the actual streaming and
> also sets the content-disposition: attachment; filename=''.
>
> And here the trouble starts. If we have, say, cyrillic names of the files
> to present to user, they are displayed incorrectly in browser. ASCII is
> okay, but as soon as it comes down to non-english, encoding is broken.
> That's a good article describing problem in general -
> http://stackoverflow.com/questions/93551/how-to-encode-the-filename-parameter-of-content-disposition-header-in-http
> (it
> is a problem of browsers, and not Wicket). The good solution seen there is
> to add content-disposition header without a filename, and make download
> happen off the URL which is ending in the desired filename.
>
> Now, the question - how do i do it in wicket? Say, I have an AjaxLink
> within page, which has an AjaxDownload attached to it. AjaxDownload is an
> anonymous inner class and is using some page's model to generate its data.
> The callback URL of this behavior is standard and is starting with ?, e.g.
> I can not add /filename.ext prior to it, it would break wicket's request
> target location with 404 as a result.
>
> The only idea I have at the moment is to mount the page with a Hybrid
> coding strategy, thus the filename would then be considered just as one of
> the parameters by the page, but the solution seems to be a little smelly.
>
> Did anyone face the same problem?
>
> Great thanks and appreciation in advance!
>
> with kindest regards,
>
> --
> Alexander Cherednichenko
> [ the only way out is the way up ]



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org