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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -