Reputation: 1206
I am trying to implement a web application using play framework as a replacement for old http server implementation that is interfacing the old non-browser legacy http client.
That client is written in Delphi and it is posting data directly in the body of a request with some header information about it.
I thought I would get something in
request.body /* In the play controller */
but nothing is there.
See the code below:
public static void uploadPicture() {
InputStream data = request.body;
String fx = Play.getFile("").getAbsolutePath()+File.separator+"uploads"+File.separator+"test.jpg";
File f = new File(fx);
FileOutputStream moveTo = new FileOutputStream(fx);
try {
byte[] b = new byte[4096];
for (int x = 0; (data.read(b)) != -1;){
moveTo.write(b, 0, x);
}
} finally{
moveTo.close();
}
}
EDIT:
To clarify my point : I went and I created a simple Dynamic Web Project in eclipse HttpServlet
and in doPost()
method when I get the request.getInputStream()
it contains the file that is sent from the legacy client.
Play is doing something to the body of the request!?
What are my options?
Thanks.
Irfan
Upvotes: 1
Views: 1906
Reputation: 1206
Ok, it was a bug in Play 1.2.4. I installed latest version 1.2.5 and everything works out of the box.
You can access raw body of a request in request.body
in the controller.
Upvotes: 1