In Java Http request, we can do this to make multipart HTTP POST.
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
FileBo
The accepted answer didn't work with play 2.5. Also the answer in play 2.6 documentation didn't work for 2.5.
The below worked fine:
Http.MultipartFormData.FilePart part = new Http.MultipartFormData.FilePart("fileKey",
"abc.zip", "multipart/form-data",
FileIO.fromFile(new File("/home/testData/abc.zip")));
List>> data = Arrays.asList(part);
Http.RequestBuilder requestBuilder = AuthFakeRequest.getAuthFakeRequest(routes.MyController.uploadZip()).method(POST)
.bodyMultipart(data, mat);
Result result = route(app, requestBuilder);
For mat
and app
objects they are obtained when inheriting play.test.WithApplication
class.