Created
June 24, 2015 05:04
-
-
Save cdmckay/5f05cbcb5327259df1cf to your computer and use it in GitHub Desktop.
An example of how to use MultipartFormDataWriteable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.libs.ws.WS | |
import play.api.mvc.MultipartFormData.FilePart | |
import play.api.mvc.MultipartFormData | |
import utilities.MultipartFormDataWriteable._ | |
... | |
val url = "https://example.com" | |
val dataParts = Map( | |
"foo" -> Seq("bar"), | |
"alice" -> Seq("bob") | |
) | |
val file = new jave.io.File(... path to a jpg ...) | |
val fileParts = Seq(new FilePart("attachment", "foo.jpg", Some("image/jpeg"), file) | |
val multipartFormData = MultipartFormData(dataParts, fileParts, Seq(), Seq()) | |
WS.url(url).post(multipartFormData) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what is
import utilities.MultipartFormDataWriteable._
the old ning methods don't work and yours seems promising on 2.4.x
I found it http://cdmckay.org/blog/2015/06/24/how-to-add-support-for-posting-multipart-forms-to-the-play-scala-ws-library/
but it still doesnt work in play2.4 x :(