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.
CC
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
use following method to return response as file
RenderBinary(java.io.File file, java.lang.String name)
To see API follow this link .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.