I will show it to you once it's ready. I'm having some problems with
swfupload (not due to lift),
it's my inexperience with flash and javascript. I'll let you know once
I get this all sorted out. Once I get this sorted it's tempting to
make some kind of plugin (component) as I'm gonna be using swfupload
for multiple projects of mine. Will look into that later though.

On Jan 11, 9:13 pm, "David Pollak" <[email protected]>
wrote:
> Sure thing.
> Is your app public?  I love to see what people have done with Lift...
>
>
>
> On Sun, Jan 11, 2009 at 8:47 AM, Alli <[email protected]> wrote:
>
> > Thanks chaps, that did the trick.
>
> > Cheers,
> > Alfred
>
> > On Jan 11, 3:25 pm, Marius <[email protected]> wrote:
> > > Ummm ... Does it really need to return a DispatchPf? It could create
> > > internally the DispatchPF as just append it to LiftRules dispatch
> > > list.
>
> > > On Jan 11, 5:09 pm, "David Pollak" <[email protected]>
> > > wrote:
>
> > > > I think something like:
> > > > createFileHandler(path: List[String], nameOfFileParam: String,
> > > > returnContentType: String)(f: Array[Byte] => Array[Byte]): DispatchPF
>
> > > > would be a cool method.  It would build the DispatchPF for you and all
> > you
> > > > need do is supply the transformation function.  If you wanted to get
> > fancy
> > > > and do access control, etc., you'd have to write your own.
>
> > > > On Sun, Jan 11, 2009 at 7:00 AM, Marius <[email protected]>
> > wrote:
>
> > > > > I wonder if it makes sense to have a built-in DispatchPF to ease up
> > > > > things so that user to just provide a  (FileParamHolder =>
> > > > > LiftResponse)
>
> > > > > perhaps something like:
>
> > > > > FIleUploader.init {
>
> > > > >  case (path, fileParamHolder ) => a LiftResponse
>
> > > > > }
>
> > > > > ... internally it will just add itsellf as a DispathPf
>
> > > > > Br's,
> > > > > Marius
>
> > > > > On Jan 11, 3:43 pm, "David Pollak" <[email protected]>
> > > > > wrote:
> > > > > > Alli,
> > > > > > Yes, I think your want to go with a DispatchPF to handle the
> > destination
> > > > > of
> > > > > > the POST request from your Flash component.
>
> > > > > > DispatchPF {
> > > > > >   case r @ Req("upload" :: "thing" :: Nil, "", PostRequent) if
> > > > > > r.uploadedFiles.exists(_.name == "upload") =>
> > > > > >     () => {
> > > > > >     val uploadedFile = r.uploadedFiles.find(_.name == "upload").get
> > > > > >     val fileBytes = uploadedFile.file
> > > > > >     ... do stuff here
> > > > > >     val newFileBytes: Array[Byte]
> > > > > >     val headers: List[(String, String)]
> > > > > >     Full(InMemoryResponse(newFileBytes, headers, Nil /* no cookies
> > sent
> > > > > back
> > > > > > */, 200))
> > > > > >     }
>
> > > > > > }
>
> > > > > > Thanks,
>
> > > > > > David
>
> > > > > > On Sun, Jan 11, 2009 at 4:52 AM, Alli <[email protected]>
> > wrote:
>
> > > > > > > I'm not sure how i would hook SHtml.fileUpload into this because
> > > > > > > swfupload lets me configure an URL
> > > > > > > that it will post to for each file uploaded, I don't even  need a
> > form
> > > > > > > to do this (this is all flash/swf). I currently
> > > > > > > have a LiftView subclass that handles it and is processing it
> > like
> > > > > > > this:
>
> > > > > > > S.request match {
> > > > > > >    case Full(req) =>
> > > > > > >      req.uploadedFiles.foreach { file: FileParamHolder =>
> > > > > > >        println("Name: " + file.name)
> > > > > > >        println("File name: " + file.fileName)
> > > > > > >        resizeAndSave(file)
> > > > > > >      }
>
> > > > > > >      case _ =>
> > > > > > >    }
>
> > > > > > > I guess the only thing I need to change is using a custom
> > dispatch
> > > > > > > instead of the view in order to return my own LiftResponse
> > instead of
> > > > > > > a NodeSeq
> > > > > > > back to the client.
>
> > > > > > > Cheers,
> > > > > > > Alli
>
> > > > > > > On Jan 11, 12:37 pm, Marius <[email protected]> wrote:
> > > > > > > > Alli are you using SHtml.fileUpload ... or you want to upload
> > it
> > > > > > > > "manually" processing everything in your dispatch? .. I'd opt
> > in for
> > > > > > > > SHtml.fileUpload because there is a bunch of stuff Lift does
> > for you.
>
> > > > > > > > On Jan 11, 5:12 am, Alli <[email protected]> wrote:
>
> > > > > > > > > Yeah I think I need to add a custom dispatch function and
> > make that
> > > > > > > > > return my own response. I was actually
> > > > > > > > > hoping I could do this straight from the snippet instead of
> > having
> > > > > to
> > > > > > > > > redirect, makes the whole thing more complex.
>
> > > > > > > > > On Jan 11, 12:41 am, Marc Boschma 
> > > > > > > > > <[email protected]<marc%[email protected]>
> > <marc%[email protected] <marc%[email protected]>>
> > > > > <marc%[email protected] <marc%[email protected]> <
> > marc%[email protected] <marc%[email protected]>>>>
> > > > > > > wrote:
>
> > > > > > > > > > I'm not an expert but I would model a Response class in
> > much the
> > > > > same
>
> > > > > > > > > > way as:
>
> > > > > > > > > >    package net.liftweb.http
>
> > > > > > > > > >    object PlainTextResponse {
> > > > > > > > > >      def apply(text: String): PlainTextResponse =
> > > > > > > > > > PlainTextResponse(text, Nil, 200)
> > > > > > > > > >      def apply(text: String, code: Int): PlainTextResponse
> > =
> > > > > > > > > > PlainTextResponse(text, Nil, code)
> > > > > > > > > >    }
>
> > > > > > > > > >    case class PlainTextResponse(text: String, headers:
> > > > > List[(String,
>
> > > > > > > > > > String)], code: Int) extends LiftResponse {
> > > > > > > > > >      def toResponse = {
> > > > > > > > > >        val bytes = text.getBytes("UTF-8")
> > > > > > > > > >        InMemoryResponse(bytes, ("Content-Length",
> > > > > > > > > > bytes.length.toString) :: ("Content-Type", "text/plain") ::
> > > > > headers,
>
> > > > > > > > > > Nil, code)
> > > > > > > > > >      }
> > > > > > > > > >    }
>
> > > > > > > > > > from TextResponse.scala. Look at InMemoryResponse or
> > possibly
> > > > > > > > > > StreamingResponse in Response.scala.
>
> > > > > > > > > > Marc
>
> > > > > > > > > > On 11/01/2009, at 4:27 AM, Alli wrote:
>
> > > > > > > > > > > Hey, I have been searching the list and also the
> > liftweb.netwiki
> > > > > > > and
> > > > > > > > > > > haven't found a way to do this:
>
> > > > > > > > > > > I have a form to upload a file that I want to manipulate
> > and
> > > > > send
> > > > > > > back
> > > > > > > > > > > to the client. When sending it back I am using
> > S.setHeader to
> > > > > set
> > > > > > > the
> > > > > > > > > > > content type, disposition etc but I haven't found a way
> > to
> > > > > write
> > > > > > > the
> > > > > > > > > > > file back to the response. What I think I need is access
> > to the
> > > > > > > > > > > response's printwriter (response.getWriter()) instance.
> > Any
> > > > > help
> > > > > > > would
> > > > > > > > > > > be greatly appreciated.
>
> > > > > > > > > > > Cheers,
> > > > > > > > > > > Alli
>
> > > > > > --
> > > > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > > > Collaborative Task Managementhttp://much4.us
> > > > > > Follow me:http://twitter.com/dpp
> > > > > > Git some:http://github.com/dpp
>
> > > > --
> > > > Lift, the simply functional web frameworkhttp://liftweb.net
> > > > Collaborative Task Managementhttp://much4.us
> > > > Follow me:http://twitter.com/dpp
> > > > Git some:http://github.com/dpp
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Collaborative Task Managementhttp://much4.us
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp

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

Reply via email to