I want to stream large responses from remote servers.
For example - I used the following code to stream an image from wikimedia. The expectation was that it will stream the image back to the client in small chunks. However, it loads the entire image and then sends it to the client.
Action.async { implicit request =>
val futureResponse = ws.url(
"https://upload.wikimedia.org/wikipedia/commons/c/c7/%2271%22_on_St._Patrick%27s_Day._Washington%2C_D.C.%2C_March_17._" +
"Justice_Pierce_Butler%2C_71_years_old_today_celebrates_his_birthday_by_taking_his_morning_walk%2C_snapped_while_leaving_his_home_on_19" +
"th_LCCN2016871374.tif")
.withMethod("GET")
.stream()
futureResponse.map {
f =>
Ok.chunked(f.bodyAsSource)
}
}
I copied the entire code given in https://www.playframework.com/documentation/2.8.x/ScalaWS#Processing-large-responses but it too does not work
Play version is 2.8.19.