On Sun, Jun 28, 2009 at 12:08 AM, Thiago H. de Paula Figueiredo <
thiagohp@...> wrote:
> I am able to do (1) using StreamResponse but not sure how to solve (2)-
>> send a Page response back and a file as an attachment.
>>
>
>
> To redirect the user to a page (Login, for example), just return a page
> instance (got through @InjectPage) or the page class instance (Login.class)
> in the onActivate() method instead of the StreamResponse.
>
> As far as I know, you can't return a page and an attachment in the same
> request. Using Javascript (window.location = "...";) in the returned page,
> you can instruct the user's browser to make another request (in this case, a
> file as an attachment).
>
The typical approach is to return a page that either uses Javascript or a
Meta redirect to download the file, and include in the page a link that
allows the user to click to do the download if the other approaches fail.
Look at lots of popular download sites to get ideas -- anywhere where you
get a page like, "Your download should begin shortly; please _click here_ to
download if your download does not start."
- Geoffrey
--
Geoffrey Wiseman
http://www.geoffreywiseman.ca/