$scope.displayTaskOutput = function() {
console.log("Selected jobId is...."+$scope.widgetForm.query_config.selectedTasks.jobId)
console.log("Selected File is....."+$scope.widgetForm.query_config.selectedFiles)
$http({
url: baseUrl+"/"+$scope.widgetForm.query_config.selectedTasks.jobId+"/download",
method: "GET",
params: {fileName:$scope.widgetForm.query_config.selectedFiles},
headers: {
'x-api-key': apiKey,
'Content-Type': 'application/json'
},
data: ''
}).success(function(data, status) {
//console.log(data);
$scope.taskOutputData = data
var mimeType = 'image/pjpeg';
var link = document.createElement('a');
link.setAttribute('download', $scope.widgetForm.query_config.selectedFiles);
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(data));
link.click();
}).error(function(data, status) {
console.log("failed:" + status);
console.log("data : " + data.message);
});
};
在这里,当我尝试下载文本文件时,它正在下载并打开正常但不是文本文件当我尝试下载jpg,pdf,png文件时它会被下载但是当我尝试时已损坏打开它它不会打开并说“文件无法打开,因为它包含错误”