无法使用路径保存文件

Cannot save file with path

我正在使用 httpModule 调用保管箱休息服务来下载文本文件。当我将它下载到内部存储时,它看起来很高兴,但后来我无法使用默认应用程序打开文本文件。所以现在我将下载位置指向外部存储,但出现错误 'Error: Cannot save file with path: /storage/emulated/0/myNewDir'。我已将您的 write_external_storage 和 read_external_storage 权限添加到清单中。这是我的代码:

HomePage.prototype.getFile = function() {
var filePath = fs.path.join(fs.knownFolders.currentApp().path, "myFile.txt");
storage.createDirectory("myNewDir");

httpModule.getFile({
    url: "https://content.dropboxapi.com/2/files/download",
    method: "POST",
    headers: { "Content-Type": "", 
               "Dropbox-API-Arg": JSON.stringify({"path": "/path/file"}), 
               "Authorization": "*****" },      
}, storage.buildAbsolutePath()+"/myNewDir").then(function (response) {
    console.log(JSON.stringify(response));          
}, function (e) {
    console.log("Error occurred " + e);
});}

你需要在getFile函数中指定文件名,像这样:

httpModule.getFile({
    url: "https://content.dropboxapi.com/2/files/download",
    method: "POST",
    headers: { "Content-Type": "", 
               "Dropbox-API-Arg": JSON.stringify({"path": "/path/file"}), 
               "Authorization": "*****" },      
}, storage.buildAbsolutePath()+"/myNewDir/myFile.txt").then(function (response) {
    console.log(JSON.stringify(response));          
}, function (e) {
    console.log("Error occurred " + e);
});}