java - Angular download file from server -
i have application has java on play framework backend , angular frontend.
i have end point in java show pdf when accessing endpoint. prefer use angular download file.
java backend this
response().setcontenttype("application/pdf"); response().setheader("content-disposition", "inline; filename='report.pdf'"); return ok(bytearrayoutputstream.tobytearray());
the angular frontend this
$http({method: 'get', url: 'report/2'}). success(function(data, status, headers, config) { var hiddenelement = document.createelement('a'); var str = string.fromcharcode.apply(null, new uint8array(data)); hiddenelement.href = 'data:application/pdf;base64,' + str; hiddenelement.target = '_blank'; hiddenelement.download = 'myfile.pdf'; hiddenelement.click(); })
however, when downloaded file, content not there anymore. not sure if it's decoding issue.
thanks in advance help.
Comments
Post a Comment