I can’t upload images to Chrome - Play! Framework

Asked

Viewed 198 times

1

Hello,

I’m using Play! Framework and I’m having a problem trying to upload images, especially in Google Chrome:

[error] play - Exception caught in RequestBodyHandler
java.nio.channels.ClosedChannelException: null
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.cleanUpWriteBuffer(AbstractNioWorker.java:433)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromUserCode(AbstractNioWorker.java:128)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:99)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:36)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:779)

In client-side, this is the code that makes the request to upload the images:

var formData = new FormData();
for (var i = 0; i < $scope.images.length; i++) {
  formData.append('picture' + i, $scope.images[i]);
}

$http.post('/resource/ad/' + id + '/upload', formData, {
  transformRequest: angular.identity,
  headers: {'Content-Type': undefined}
});

On the server, it is implemented in this way:

play.mvc.Http.MultipartFormData body = request().body().asMultipartFormData();
List<Http.MultipartFormData.FilePart> files = body.getFiles();

I changed the values of my parameters in application.conf to:

parsers.MultipartFormData.maxLength=50240K
play.http.parser.maxDiskBuffer=50240K
play.http.parser.maxMemoryBuffer=50240K

The curious thing is that only happens in Chrome, in Firefox for example, which is the other browser I use, images are normally loaded.

Does anyone have any idea what might be going on and can help me solve this problem?

Thank you!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.