I am using jersey API in my project. I stuck in a case that file needs to be downloaded but it's not. My code is as follow
@GET
@Produces("application/download")
public Response downloadFile(){
String data = getDatas();
ResponseBuilder response = Response.ok(data);
response.header("Content-Disposition","attachment;filename=UserData.txt");
response.header("charset", "UTF-8");
return Response.build();
}
I have added all the packages, paths are also fine. No Error came.
When I call this API, data comes in the response. I want this data to be in a file and in a downloadable format.
I also tried @Produces(MediaType.APPLICATION_OCTET_STREAM)
.
Please correct me if am doing wrong