null请求大型数据的主体 [英] null request body for large data

查看:127
本文介绍了null请求大型数据的主体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在post方法体中发送大量文本。
我使用Postman进行测试。
然而它工作正常,我可以读取这样的请求体:

I am sending large amount of text in the body of post method. I use Postman for testing that. However its working fine and i can read request body like this:

String text = request().body().asText();

但是当我尝试在正文中发送大量数据时,我会为文本获取null。
我也试过使用字符串生成器,但我也得到null。

But when i try to send large amount of data in the body i get null for the text. I also tried using the string builder but i also get null.

 InputStream is = new ByteArrayInputStream(request().body().asText().getBytes());
        BufferedReader br = new BufferedReader(new InputStreamReader(is));

有没有办法解决这个问题?

Is there a way to get that fixed??

推荐答案

默认播放将上传数据大小限制为100kb到文本解析器(*)。可以使用 parsers.text.maxLength application.conf

By default Play limits the upload data size to 100kb to text parsers(*). This can be changed to a bigger value globally using parsers.text.maxLength in application.conf

parsers.text.maxLength=4M

或在特定的回应或行动中使用

or in a specific Response or Action using

@BodyParser.Of(value = TheBodyParser.class, maxLength = 4 * 1024 * 1024)
public Result upload() {
    // (...)
}

def upload = Action(parse.text(maxLength = 4 * 1024 * 1024)) { request =>
  // ()
}

(*)缓冲内容的解析器(ex multipart form)限制为10MB,可以使用 parsers.disk.maxLength

(*) To parsers that buffer content (ex multipart form) the limit is 10MB and can be changed using parsers.disk.maxLength

这篇关于null请求大型数据的主体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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