4

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

3
  • The data you are trying to post is bigger than 128k (the default in Play)? If so change it adding to aplication.conf parsers.text.maxLength=4M, for example Commented Jan 29, 2015 at 9:56
  • @Salem in that case i dont think play continues with the controllers logic. Instead i think it throws a bad request or something like that. This is an example link Commented Jan 29, 2015 at 10:25
  • thanks, adding parsers.text.maxLength=4M to application.conf worked for me! Commented Jan 29, 2015 at 10:36

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.