I have a rest api to download a file from server ,
@Path("/file")
public class FileService {
@GET
@Path("/get")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response getFile(String filePath) {
File file = new File(filePath);
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition",
"attachment; filename=\"file_from_server.log\"");
return response.build();
}
}
How to receive the file object from the javax.ws.rs.core.Response and write the content of the file in local without using browser. I am tried below ,
InputStream in = response.readEntity(InputStream.class);
But it is not working.