I have requirement like i want to download a file through rest web services but it can be jpg, jpeg, pdf, png anything I have written code like below but irts not working properly.
@GET
@Path("/UploadProfileImage")
// @Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getFileuploaded(@HeaderParam("filetoopen")String filetoopen) {
ResponseBuilder response=null;
File file = new File(filetoopen);
System.out.println(filetoopen);
response = Response.ok((Object) file);
response.header("Content-Disposition","attachment; filename=\"" + filetoopen + "\"");
return response.build();
}
here in filetoopen parameter i am passing fully qualified name of file. means with location. i am trying to download file with POSTMAN API but it not coming properly. screenshot attached.