Reputation: 2928
I'm working on a play framework 2 application and I would like to call a WebService and send a file ( an image ). I found the WS class but I cannot find how to send a file using it. What I found is this :
WS.url("http://localhost:9001/post").post("content")
But I did not managed to send a file using a POST request.
Can someone tell me how to do it ?
Thanks.
C.C.
Upvotes: 1
Views: 3118
Reputation: 500
use following method to return response as file
RenderBinary(java.io.File file, java.lang.String name)
To see API follow this link.
Upvotes: 0
Reputation: 702
With Play > 2.0 this should do the trick:
File file = new File("yourPath");
WS.url("/post/url").post(file);
Being able to add a parameter identifying your file the request should be send using multipart/form-data. This Post shows how to do it with Play! - https://stackoverflow.com/a/18723326/2788883
Upvotes: 3