开发者

Grails, getting InputStream from Controller (or even Servlet)

I'm trying to get inputStream from request, but it's always empty. Any idea how to get the contents of 开发者_Python百科it? I'm trying to make a DataInputStream from it.


Are you uploading multipart requests? The request may have already been processed into a Spring MultipartRequest by Grails in which case you can use getFile() to get the upload contents.

If not, then request.inputStream should work fine.

cheers

Lee


For me it works when I request the controller method with "application/octet-stream" MIME and send some data within the request. Than in the controller I can simply do:

import org.apache.commons.io.IOUtils

def test() {
   byte[] requestData = IOUtils.toByteArray(request.getInputStream())
}

That's it :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜