i trying sent file through multi-part form data using scala , play 2.4.6.
def sendfile(file: filepart[temporaryfile]): option[future[unit]] = { val asynchttpclient:asynchttpclient = ws.client.underlying val postbuilder = asynchttpclient.preparepost(s"${config.ocrprovider.host}") val multipartpost = postbuilder .addbodypart(new stringpart("access_token",s"${config.ocrprovider.accesstoken}")) .addbodypart(new stringpart("typename",s"${config.ocrprovider.typename}")) .addbodypart(new stringpart("action",s"${config.ocrprovider.actionupload}")) .addbodypart(new filepart(???) }
i'm new on scala , play, , sent file method attribute new filepart. possible?
yes,
.addbodypart(new filepart("myfile", new file("app/controllers/application.scala")))
you find full example of post in play-scala in answer here: sending multi part form data in post method in play/scala
Comments
Post a Comment