Reputation: 2346
My server side code is the following (just for the sake of testing it):
def upload = Action(parse.maxLength(maxLength = 10*1024, parser.multipartFormData)) {
implicit request =>
Logger.info("data: " + request.body.dataParts)
Logger.info("file: " + request.body.file("picture"))
Logger.info("req: " + request.contentType)
Logger.info("req body: " + request.body)
Ok("File has been uploaded")
}
My client side code is a simple form that has an input of type file.
@helper.form(action = routes.Application.upload, 'enctype -> "multipart/form-data") {
<p>
<input type="text" name="name" />
</p>
<p>
<input id="imageFile" type="file" name="picture" accept="image/*" />
</p>
<p>
<input type="submit" value="Save" />
</p>
}
The problem is that if you try to upload files that are bigger than 10KB the browser will hang waiting for the server to finish even though it appears that the server has finished consuming the request. How to solve it?
Upvotes: 0
Views: 441
Reputation: 2346
Unfortunately, there seems to be a problem related to this in Play 2.0.4 and the browser will hang waiting for the file to finish uploading even though the request body has been consumed in the server side. A discussion regarding the issue can be found here and it was reported here (play doesn't finish consuming request if maxlength is reached).
Fortunately, this has been resolved in Play 2.1 and the first release candidate is already available. So, the best thing to do would be to migrate your app to Play 2.1.
Upvotes: 1