4546

Play WS (2.2.1): post/put large request

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?

Answer1:

WS underlying client takes InputStream. Access it like this:

import com.ning.http.client.AsyncHttpClient val client:AsyncHttpClient = WS.client

Answer2:

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.

Recommend

  • Does the failbit effect the call ignore on cin?
  • Unzip archive in .Net CORE 1.0
  • Streaming screenshots over WebRTC as a video stream from iOS
  • Angular2 Response for preflight is invalid (redirect) from some GET requests
  • How to get current document uri in XSLT?
  • saving file generated by TCPDF
  • Alternative To body {overflow:scroll;} That Will Prevent Page Jostling/Wriggling?
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • Xcode 4 NSLog Macro link in Xcode 3
  • print() is showing quotation marks in results
  • Content-Length header not returned from Pylons response
  • Bad request using file_get_contents for PUT request in PHP
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Highlight one bar in a series in highcharts?
  • How to access EntityManager inside Entity class in EJB3
  • Different response to non-authenticated users and AJAX calls
  • MySQL WHERE-condition in procedure ignored
  • Deserializing XML into class C#
  • Trying to switch camera back to front but getting exception
  • vba code to select only visible cells in specific column except heading
  • Web-crawler for facebook in python
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • Calling of Constructors in a Java
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • PHP: When would you need the self:: keyword?
  • trying to dynamically update Highchart column chart but series undefined
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • coudnt use logback because of log4j
  • How do I configure my settings file to work with unit tests?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • Is it possible to post an object from jquery to bottle.py?
  • Programmatically clearing map cache
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML
  • java string with new operator and a literal