2

I'm using Play.WS to issue http requests. My goal is to send a put request with a large file.

val requestHolder = WS.url("http://" + host)
requestHolder.put(???)

I don't know what should be the type of ??? to stream the body. The requestHolder has a put(File file) method - which I can't use because I don't have the file - and put[T](T body) where T can be anything as long as you have an instance of Writable[T].

There are some default writables defined for json, text, xml, etc. But non for an InputStream for example.

The documentation gives a (brief) hint to handle large responses but nothing about large requests (http://www.playframework.com/documentation/2.2.x/ScalaWS)

Anyone knows how to define a writable that would accept an InputStream? Or maybe an Iteratee?

vptheron
  • 7,426
  • 25
  • 34

2 Answers2

2

WS underlying client takes InputStream. Access it like this:

import com.ning.http.client.AsyncHttpClient

val client:AsyncHttpClient = WS.client
Dominykas Mostauskis
  • 7,797
  • 3
  • 48
  • 67
1

Unfortunately, this isn't supported yet.

There is a little discussion about it here:

https://github.com/playframework/playframework/pull/1510

And we're hoping that for Play 2.3, we will have a solution to allow it.

James Roper
  • 12,695
  • 46
  • 45