如何使用Amazon S3 GetObject的-Aws SDK 2.2.6时指定本地目标路径 [英] How to specify local destination path when using Amazon S3 GetObject -Aws sdk 2.2.6
问题描述
下面code成功地使用从我的S3存储下载的数据AWS-SDK 2.2.6。
The following code successfully downloads data from my S3 storage using 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();
});
};
});
我怎么能修改此code将下载的数据保存到一个特定的本地文件路径的前端。
How can I modify this code to save the downloaded data to a specific local file path on the front end.
推荐答案
在FS是与服务器的文件系统进行交互的nodejs相关的对象,但这个片段似乎是前端code
The "fs" is a nodejs related object for interacting with the server file system, but this snippet appears to be front end code.
如果你想修改该文件存储在前端,你不能,这是由浏览器来控制。如果你可以节省服务器上的文件,可以使用FS对象。
If you're trying to alter where the file stores for the front end, you can't, that's controlled by the browser. If you're saving a file on the server, you can use the fs object.
这篇关于如何使用Amazon S3 GetObject的-Aws SDK 2.2.6时指定本地目标路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!