download and continue

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

download and continue

Jon Paynter-2
Im trying to setup my application to provide a download link to a generated file, and then continue with the application flow after the user clicks the download link.  My application generates a script file, then provides a download link.  When the user clicks on the download link, it has to record that the download happened, and then exit the script generation component.

I have the following method:

downloadScript
    self markAsApplied.
    self requestContext respond: [ : response |
        response contentType: 'text/plain';
        attachmentWithFileName: 'EMS.conf';
        nextPutAll: self generatedScript.
    ].

Which marks as applied, and causes the browser to download the file. But I afterwards I need to call: "self answer: true"  so the component will exit.
just adding: "self answer: true" at the end of the method doesnt work.

I found WARequestContext>>respondAndContinue:  but that did not work -- the block argument is a url instead of the response object

How do I resume processing after doing a download?

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: download and continue

mmimica
Jon Paynter wrote:
> Which marks as applied, and causes the browser to download the file.
> But I afterwards I need to call: "self answer: true"  so the component
> will exit.
> just adding: "self answer: true" at the end of the method doesnt work.

I asked the very same question not a while ago. The show answer is: you
can't. HTTP server can answer the client with only one response, either
a file download or a next HTML page. Its a design issue.
You could come up with some javascript that redirects shortly after the
download has started but personally, I like to keep things as they were
designed to work.

--
Milan Mimica
http://sparklet.sf.net

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: download and continue

carlo.t
In reply to this post by Jon Paynter-2

My Seaside is rusty but why can't you try:

                html anchor
                        document: file contents
                                mimeType: file contentType
                                fileName: file fileName ;
                        callback: [self answer: true];
                        text: file fileName.

where file is a WAFile object e.g.
         WAFile new
                contents: multiStream contents ;
                fileName: self action , '_RESPONSE.zip' ;
                contentType: 'application/zip'

----------------------------------------------------------------------

Message: 1
Date: Tue, 26 Jul 2011 11:15:23 -0700
From: Jon Paynter <[hidden email]>
Subject: [Seaside] download and continue
To: [hidden email]
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="iso-8859-1"

Im trying to setup my application to provide a download link to a generated
file, and then continue with the application flow after the user clicks the
download link.  My application generates a script file, then provides a
download link.  When the user clicks on the download link, it has to record
that the download happened, and then exit the script generation component.

I have the following method:

downloadScript
   self markAsApplied.
   self requestContext respond: [ : response |
       response contentType: 'text/plain';
       attachmentWithFileName: 'EMS.conf';
       nextPutAll: self generatedScript.
   ].

Which marks as applied, and causes the browser to download the file. But I
afterwards I need to call: "self answer: true"  so the component will exit.
just adding: "self answer: true" at the end of the method doesnt work.

I found WARequestContext>>respondAndContinue:  but that did not work -- the
block argument is a url instead of the response object

How do I resume processing after doing a download?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110726/67b44e54/attachment-0001.htm

------------------------------


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: download and continue

Julian Fitzell-2
Both #document:mimeType:fileName: and #callback: set the href
attribute of the anchor, so one will override, the other.

As I responded to the earlier thread about this question, there are
ways of removing the called component prior to responding with the
document, but HTTP only allows for a single response per request.
Either you return an HTML page or you return a document; you can't
return both. To work around that you'd have to play tricks with
automatic refresh, iframes, javascript or the like.

Julian

On Wed, Jul 27, 2011 at 9:59 AM, Carlo <[hidden email]> wrote:

>
> My Seaside is rusty but why can't you try:
>
>                html anchor
>                        document: file contents
>                                mimeType: file contentType
>                                fileName: file fileName ;
>                        callback: [self answer: true];
>                        text: file fileName.
>
> where file is a WAFile object e.g.
>         WAFile new
>                contents: multiStream contents ;
>                fileName: self action , '_RESPONSE.zip' ;
>                contentType: 'application/zip'
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 26 Jul 2011 11:15:23 -0700
> From: Jon Paynter <[hidden email]>
> Subject: [Seaside] download and continue
> To: [hidden email]
> Message-ID:
>        <[hidden email]>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Im trying to setup my application to provide a download link to a generated
> file, and then continue with the application flow after the user clicks the
> download link.  My application generates a script file, then provides a
> download link.  When the user clicks on the download link, it has to record
> that the download happened, and then exit the script generation component.
>
> I have the following method:
>
> downloadScript
>   self markAsApplied.
>   self requestContext respond: [ : response |
>       response contentType: 'text/plain';
>       attachmentWithFileName: 'EMS.conf';
>       nextPutAll: self generatedScript.
>   ].
>
> Which marks as applied, and causes the browser to download the file. But I
> afterwards I need to call: "self answer: true"  so the component will exit.
> just adding: "self answer: true" at the end of the method doesnt work.
>
> I found WARequestContext>>respondAndContinue:  but that did not work -- the
> block argument is a url instead of the response object
>
> How do I resume processing after doing a download?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110726/67b44e54/attachment-0001.htm
>
> ------------------------------
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside