I have a problem trying to download a file using RestFul. I'm setting the Content-Disposition and the attachment, but when the file is downloaded, it has a random name.
@GET
@Path("{type}/xls")
@Produces("application/vnd.ms-excel")
public Response downloadExcel(@Context HttpHeaders headers...) {
...
File file = getFileToDownload();
Response.ResponseBuilder builder = Response.ok(file);
String fileName = file.getName();
builder.header("Content-Disposition", "attachment; filename=" + fileName);
...
return builder.build();
For example, if the file name is "file001.xls", the response is:
Response-Code: 200
Content-Type: application/vnd.ms-excel
Headers: {Content-Disposition=[attachment; filename=file001.xls], Content-Type=[application/vnd.ms-excel], Date=[Tue, 01 Mar 2016 16:18:19 GMT]}
But the downloaded file is named like this: 8fecd36a-a5aa-4b04-b757-4c38ddea11db.xls
Could you help me, please! :-)