Bruna Colnago
unread,Jan 31, 2011, 9:22:09 AM1/31/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Lift
I'm trying to download a txt file with an ajaxBoutton using
JsCmds.RedirectTo.
bind("form","download" -> bDownload)
def bDownload:NodeSeq = ajaxButton("Download",downloadForm _)
private def downloadForm : JsCmd = {
JsCmds.RedirectTo("/result)
}
At my boot.scala I've add:
class Boot {
def boot {
LiftRules.dispatch.prepend {
case Req("result" :: _, _ , _) => () => {
val str="Hello world\n"
val headers:List[(String, String)] =
List(("ContentType","application/vnd.text"),
("Content-Length",str.length.toString),
("Content-Disposition","attachment;filename=\"hello.txt
\""))
val data = str.getBytes("UTF-8")
Full(StreamingResponse(new java.io.ByteArrayInputStream(data),
() => {},data.length, headers, Nil, 200))
}
}
It works fine on Firefox, but the file won't download on chrome.
Could anyone help'me finding where is the problem?