I am using angular to access a rest API which return ResponseEntity
of Byte Array like return new ResponseEntity<byte[]>(pdf, headers, HttpStatus.OK);
My code in front side is as below which I got from How to read pdf stream in angularjs
$http.post("http://localhost/app/report/csd/" + projectId, obj, {responseType: 'arraybuffer'})
.success(function (data, status, headers, config) {
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
$window.open(fileURL);
})
.error(function (err) {
callback.error(err);
});
},
}
The file name is being set as header in Rest Api and returned with response as below:
headers.add("Content-Disposition", new StringBuilder("inline; filename=\"").append("report.pdf").append("\"").toString());
I want above file name to be set to the Bolb object, and new window URL in address Bar should be the URL of post request.
Hence after $window.open(fileURL)
call the address bar should display URL as
http://localhost/app/report/csd/{{project_id}} and generated file should be of name : report.pdf.
currently The URL is coming as blob:http%3A//localhost%3A8080/88506783-779c-4525-bdc3-329029d23257"
and file with name 88506783-779c-4525-bdc3-329029d23257.pdf
How can I achieve the above please help!