Skip to content
Browse files

Problems with up.loaded files with Netty : http://github.com/pepite/P…

  • Loading branch information...
1 parent 8a68830 commit a61415e63931a28a39f9a84f01d6fd0bd3729866 @pepite pepite committed
View
4 samples-and-tests/test/app/controllers/Application.java
@@ -15,8 +15,8 @@ public static void index() {
public static void upload(File file) throws Exception {
Logger.info("File is " + file.getAbsolutePath() + "]");
- FileUtils.copyFile(file, new File(Play.getFile("data/"), file.getName()));
+ FileUtils.copyFile(file, new File(Play.getFile("/data/"), file.getName()));
Logger.info("File size [" + file.length() + "]");
}
-}
+}
View
2 samples-and-tests/test/app/views/Application/index.html
@@ -7,4 +7,4 @@
<input type="submit">
-</form>
+</form>
View
2 samples-and-tests/test/conf/application.conf
@@ -63,7 +63,7 @@ date.format=dd-MM-yyyy
# ~~~~~
# Specify log level for your application.
# If you want a very customized log, create a log4j.properties file in the conf directory
-# application.log=INFO
+application.log=TRACE
#
# More logging configuration
# application.log.path=/log4j.properties
View
6 src/play/modules/netty/HttpServerPipelineFactory.java
@@ -25,7 +25,6 @@
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
import org.jboss.netty.handler.stream.ChunkedWriteHandler;
@@ -38,13 +37,11 @@
public ChannelPipeline getPipeline() throws Exception {
Integer max = Integer.valueOf(Play.configuration.getProperty("play.netty.maxContentLength", "-1"));
- Integer threshold = Integer.valueOf(Play.configuration.getProperty("play.netty.threshold", "8192"));
-
+
ChannelPipeline pipeline = pipeline();
pipeline.addLast("decoder", new HttpRequestDecoder());
pipeline.addLast("aggregator", new StreamChunkAggregator(max));
- //pipeline.addLast("aggregator", new HttpChunkAggregator(max));
pipeline.addLast("encoder", new HttpResponseEncoder());
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
@@ -54,4 +51,3 @@ public ChannelPipeline getPipeline() throws Exception {
return pipeline;
}
}
-
View
2 src/play/modules/netty/Server.java
@@ -60,7 +60,7 @@ public Server() {
// Setup the http server for netty
ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
- Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
+ Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
bootstrap.setPipelineFactory(new HttpServerPipelineFactory());
bootstrap.bind(new InetSocketAddress(address, httpPort));
View
5 src/play/modules/netty/StreamChunkAggregator.java
@@ -64,10 +64,10 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
return;
}
-
HttpMessage currentMessage = this.currentMessage;
File localFile = this.file;
if (currentMessage == null) {
+
HttpMessage m = (HttpMessage) msg;
if (m.isChunked()) {
final String localName = UUID.randomUUID().toString();
@@ -79,6 +79,7 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
if (encodings.isEmpty()) {
m.removeHeader(HttpHeaders.Names.TRANSFER_ENCODING);
}
+
this.currentMessage = m;
this.file = new File(Play.tmpDir, localName);
this.out = new FileOutputStream(file, true);
@@ -104,7 +105,7 @@ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
HttpHeaders.Names.CONTENT_LENGTH,
String.valueOf(localFile.length()));
- currentMessage.setContent(new play.server.FileChannelBuffer(localFile));
+ currentMessage.setContent(new FileChannelBuffer(localFile));
this.out = null;
this.currentMessage = null;
this.file = null;

0 comments on commit a61415e

Please sign in to comment.
Something went wrong with that request. Please try again.