declaring FilePart field

132 views
Skip to first unread message

Salil Wadnerkar

unread,
Jul 24, 2012, 11:47:06 AM7/24/12
to play-fr...@googlegroups.com
Hi,

I am building a form that takes a multipart file input.

package controllers
import play.api.data.Form
import play.api.data.Forms._
import play.api.mvc.MultipartFormData.FilePart
import play.api.libs.Files.TemporaryFile

  val bookForm = Form(
    tuple(
      "name" -> nonEmptyText,
      "file" -> mapping[FilePart[TemporaryFile]] // <=== Here is the compilation error
    )   
  )


How should I declare my file input form field?

Thanks
Salil

Guillaume Bort

unread,
Jul 24, 2012, 12:51:15 PM7/24/12
to play-fr...@googlegroups.com
You can't do that. You have to handle the form itself and the attached
files separately. Check the documentation:

http://www.playframework.org/documentation/2.0.2/ScalaFileUpload
> --
> You received this message because you are subscribed to the Google Groups
> "play-framework" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/play-framework/-/CG1X5s5pHe0J.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to
> play-framewor...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/play-framework?hl=en.



--
Guillaume Bort, http://guillaume.bort.fr

Salil Wadnerkar

unread,
Jul 24, 2012, 9:52:23 PM7/24/12
to play-fr...@googlegroups.com
Thanks, but I also need this field to be part of a form that has other
form inputs inputs like text. So, without declaring this form, how can
I extract elements from it?
My understanding is I need to declare the form object first and then
call bindFromRequest on that.

Salil Wadnerkar

unread,
Jul 25, 2012, 7:24:00 AM7/25/12
to play-fr...@googlegroups.com

Modifying the subject according to the guideline.
Let me know how I can declare a form that has file part as a field.

Reply all
Reply to author
Forward
0 new messages