Phonegap cordova-plugin-file не создал ни одного файла - PullRequest
0 голосов
/ 10 апреля 2019

PhoneGap Cordova-плагин-файл не работает в моей телефонной пробке.Он не создает никаких текстовых файлов.

Я уже пробовал код, указанный в официальной ссылке.https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/#persistent

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {

function onErrorCreateFile() {
console.log("Create file fail...");}

function onErrorLoadFs() {
console.log("File system fail...");
}

function onErrorReadFile() {
console.log("Read File fail...");
}

function displayFileData(data){
// alert(data);
}

function readFile(fileEntry) {

fileEntry.file(function (file) {
var reader = new FileReader();

reader.onloadend = function() {
console.log("Successful file read: " + this.result);
displayFileData(fileEntry.fullPath + ": " + this.result);
};

reader.readAsText(file);

}, onErrorReadFile);
}

function createFile(dirEntry, fileName, isAppend) {
// Creates a new file or returns the file if it already exists.
dirEntry.getFile(fileName, {create: true, exclusive: false}, function(fileEntry) {

writeFile(fileEntry, null, isAppend);

}, onErrorCreateFile);

}

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fs) {

console.log('file system open: ' + fs.name);
fs.root.getFile("newPersistentFile.txt", { create: true, exclusive: false }, function (fileEntry) {

console.log("fileEntry is file?" + fileEntry.isFile.toString());
// fileEntry.name == 'someFile.txt'
// fileEntry.fullPath == '/someFile.txt'
writeFile(fileEntry, null);

}, onErrorCreateFile);

}, onErrorLoadFs);

}

Ожидается создание файла newPersistentFile.txt.Но ничего не было создано ни в одном каталоге.

...