1
以下代碼使用Aws-sdk 2.2.6成功從我的S3存儲中下載數據。如何在使用Amazon S3 GetObject時指定本地目標路徑-Aws sdk 2.2.6
return $scope.download = function(fileName, indexf) {
var bucket, params, test;
$scope.videoFileDownload[indexf] = true;
test = 0;
AWS.config.update({
accessKeyId: 'mykey',
secretAccessKey: 'mysecret'
});
AWS.config.region = 'us-west-2';
bucket = new AWS.S3({
params: {
Bucket: 'mybucket'
}
});
params = {
Key: fileName
};
return bucket.getObject(params, function(err, data) {
if (err) {
setAlert(true, 'alert alert-danger', 'Error!', err);
return false;
} else {
$scope.videoFileDownload[indexf] = false;
setAlert(true, 'alert alert-success', 'Success!', 'File Downloaded');
setTimeout((function() {
$scope.uploadProgress = 0;
$scope.$digest();
}), 4000);
}
}).on('httpDownloadProgress', function(progress) {
var progresss3;
progresss3 = Math.round(progress.loaded/progress.total * 100);
$(".progress .progress-bar").css("width", progresss3 + "%");
$(".progress .progress-bar").attr("aria-valuenow", progresss3);
$scope.$digest();
});
};
});
如何修改此代碼以將下載的數據保存到前端的特定本地文件路徑。
我可以看到在前端.....下載進度.....所以沒有辦法得到流並將其保存到本地文件? ....使用此方法下載S3文件時必須保存到服務器中? – user1526912