Any thoughts on this?  Still trying to get it to work.
Thanks

On Mar 5, 2:56 pm, DavidV <david.v.villa...@gmail.com> wrote:
> I have recreated a number of StreamingResponse methods from both the
> Loop link above and the Lift book and I still can't seem to get the
> desired effect.  I have been able to get a PlainTextResponse to work
> by using LiftRules.dispatch in the Boot, like so:
>
>     LiftRules.dispatch.prepend {
>       case Req(("analysis" :: "inprocess" :: Nil), _, _) =>
>         () => Full(PlainTextResponse("test"))
>     }
>
> However, I am unable to get any sort of streaming response to work in
> the particular snippet which contains the data I would like to use.
> Here are some of the methods I've tried:
>
>   def textResponse: Box[LiftResponse] = {
>     println("TEXT RESPONSE")
>     val ab = "text would go here"
>     Full(PlainTextResponse(ab,
>       ("Content-Type" -> "text/plain") :: Nil, 200
>     ))
>   }
>
>   def streamingResponseFile: Box[LiftResponse] = {
>     println("STREAMING RESPONSE FILE")
>     val file: File = new File(
>         "C:\\Source\\trunk\\eclipse\\testLift\\src\\main\\webapp\\images\
> \ultra.png"
>     )
>     val length = file.length
>     val fileInput = new java.io.FileInputStream(file)
>     Full(StreamingResponse(fileInput,
>       () => { fileInput.close },
>       length,
>       ("Content-Type" -> "image/png") :: Nil,
>       Nil,
>       200)
>     )
>   }
>
> Do I have to make a LiftRules.dispatch function in the Boot in
> addition to the StreamingResponse in my snippet?
>
> I am trying to download plain text, but it is variable and dependent
> on some parameters and other variables in the particular Snippet
> class.  Would I have to pass that data into the boot method in order
> to get the desired response?  I would prefer to handle it entirely in
> the snippet itself.
>
> Finally, I'm not really sure how exactly to handle the
> Full(StreamingResponse) once I have created it in order to actually
> download the data and save it to the client computer.  Although I
> assume the browser will handle this one I've formatted the Response
> correctly and actually have it working.
>
> Thanks again,
> David
>
> On Mar 4, 11:13 am, Marius <marius.dan...@gmail.com> wrote:
>
> > If you want todownloadthrough Lift than yes you can use
> > StreamingResponse, or simply any other LiftResponse (depending on your
> > mime-type) and use LiftRules.dispatch mechanism. But you could also
> > let the container to serve thefile. By default Lift is trying to
> > serve .html, .xhtml, .htm, .xml etc.. You can write your own rules by
> > setting
>
> > LiftRules.liftRequest = {
> >   case req => true // Pattern match whatever you like and return a
> > Boolean
>
> > }
>
> > If Lift cannot find a resource for some reason and you want the
> > container (or subsequent filters) to handle that you can set
>
> > LiftRules.passNotFoundToChain = true
>
> > On 4 mar., 17:09, DavidV <david.v.villa...@gmail.com> wrote:
>
> > > I am also looking todownloadafilefrom the server that is hosting
> > > my Lift web app.  There is a very useful fileUpload method in the
> > > SHtml class and I was wondering if there may be something similar for
> > > afiledownload?  I was unable to find anything, and searching for
> > > "Lift" or "Scala Liftdownload" on Google returns nothing but pages to
> > >downloadthe libraries, plugins or source code.  I suppose I could use
> > > the StreamingResponse, but I am already saving thefileI need to the
> > > server and it would be nice to be able todownloadit to any client
> > > computer with the typical "Browse" button, similar to the upload,
> > > Thanks,
> > > David
>
> > > On Feb 14, 3:58 pm, Gang <wangga...@gmail.com> wrote:
>
> > > > Thanks Tim, that's exactly what I'm looking for!
>
> > > > On Feb 14, 11:27 am, Timothy Perrett <timo...@getintheloop.eu> wrote:
>
> > > > > See:
>
> > > > >http://blog.getintheloop.eu/2009/3/19/understanding-lift-s-streamingr...
>
> > > > > Construct the CSV in memory and just then stuff it into a streaming 
> > > > > response as a byte array.
>
> > > > > Cheers, Tim
>
> > > > > On 14 Feb 2010, at 16:18, Gang wrote:
>
> > > > > > Hi,
>
> > > > > > I have a question and it may not be a pure Lift one.  But since I'm
> > > > > > working on a Lift app and this group is the most responsive one I 
> > > > > > have
> > > > > > seen, might just try it here.
>
> > > > > > I need todownloaddata from database in CSV format.  What is the best
> > > > > > approach within Lift framework?  Do I have to write the data on the
> > > > > > server somewhere and then provide user with a link?  I have tried to
> > > > > > google "scala, lift,filedownload...", but could not come up with
> > > > > > what I'm looking for.  Maybe I didn't use the right key words in
> > > > > > search?  Thanks in advance!
>
> > > > > > Brs
> > > > > > Gang
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google 
> > > > > > Groups "Lift" group.
> > > > > > To post to this group, send email to lift...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to 
> > > > > > liftweb+unsubscr...@googlegroups.com.
> > > > > > For more options, visit this group 
> > > > > > athttp://groups.google.com/group/liftweb?hl=en.-Hidequotedtext-
>
> > > > > - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to