Reputation: 359
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();
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??
Upvotes: 4
Views: 527
Reputation: 12986
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() {
// (...)
}
or
def upload = Action(parse.text(maxLength = 4 * 1024 * 1024)) { request =>
// ()
}
(*) To parsers that buffer content (ex multipart form) the limit is 10MB and can be changed using parsers.disk.maxLength
Upvotes: 1