此论坛之前已询问过此问题,但无法找到令人满意的解决方案。因此再次提出问题。 我正试图从互联网下载并存储文件到我的手机上的本地文件系统。我收到以下错误:未捕获的参考错误:LocalFileSystem未定义
Uncaught ReferenceError: LocalFileSystem is not defined
我到目前为止的代码是:
function storeFile(bucketName, csvfile){
var region;
s3Client.getBucketLocation(params = {Bucket: bucketName},function(err,data){
if(err) console.log("Error :: Cannot retrieve bucket location", err);
else {
console.log(data);
region = data;
}
});
var url = "http://s3-"+region+".amazonaws.com/"+bucketName+"/"+csvfile;
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,
function(fs){
filePath = fs.root.fullPath + "/" + csvfile;
fileTransfer = new FileTransfer();
fileTransfer.download(url, filePath,
function (entry) {
console.log(entry.fullPath); // entry is fileEntry object
},
function (error) {
console.log("Some error");
});
}, function(err){
console.log("Request File System failure");
});
}
我是否需要任何插件添加到我的应用程序?我已经添加了File和FileTransfer插件。顺便说一下,这个函数在onDeviceReady被触发后被调用。
编辑: 我没有与AngularJs合作。我的代码在NodeJs上。其次,我没有像离子框架等依赖性,这可能会带来问题。此相同的代码已经在其他已成功下载和存储的数据上进行了测试。我在将代码更改为从亚马逊服务器上的特定位置下载后出现问题。如果有人能为我解决这个问题,那就太好了。我可以通过代码访问存储区和区域。唯一的问题是LocalFileSystem。
[Cordova:LocalFileSystem is not defined]的可能重复(http://stackoverflow.com/questions/27985512/cordova-localfilesystem-is-not-defined) –