When attempting to download a file from my Amazon S3 bucket using Angular's ng-click, I am receiving a blank file instead of the expected content.
HTML
<div class="details-field"> RC Book
<font class="digit" >({{rcCount}})</font> : <i class="fa fa-angle-down fa-button" ng-click=download() ></i>
</div>
Angular Script
var awsUrl = https://s3.amazonaws.com/thdoc/ ;
$scope.download = function() {
$http.get(awsUrl, {
responseType: "arraybuffer"
})
.success(function(data) {
var anchor = angular.element('<a/>');
var blob = new Blob([data]);
anchor.attr({
href: window.URL.createObjectURL(blob),
target: '_blank',
download: 'RCBook_406_20170328_222831_644.jpg'
})[0].click();
})
}
If anyone has insight into resolving this issue, it would be greatly appreciated.
Thank you