播放WS(2.2.1):发布/放置大量请求 [英] Play WS (2.2.1): post/put large request

查看:61
本文介绍了播放WS(2.2.1):发布/放置大量请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Play.WS发出http请求.我的目标是发送带有大文件的放置请求.

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(???)

我不知道???的类型应该是什么?流的身体. requestHolder有一个put(File file)方法-因为我没有文件而不能使用-和put [T](T body),其中T可以是任何东西,只要您有Writable []实例即可. T].

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].

有一些为json,text,xml等定义的默认可写对象,但对于InputStream则没有.

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)

任何人都知道如何定义将接受InputStream的可写对象吗?也许是Iteratee?

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

推荐答案

WS underlying client takes InputStream. Access it like this:

import com.ning.http.client.AsyncHttpClient

val client:AsyncHttpClient = WS.client

这篇关于播放WS(2.2.1):发布/放置大量请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆