The file system access was broken after the upgrade. (Although it seems Work in the simulator?)
I received an error message stating that “the target file could not be created”, I googled it and considered changing my “full path” to “toURL()” , But to no avail. I really don’t know what to try next?
This is my download code
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {
create: true,
exclusive: false
},
function gotFileEntry(fileEntry) {
var sPath = fileEntry.toURL().replace("dummy.html", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download(
"https://dl.dropbox.com/u/13253550/db02.xml",
sPath + "database.xml",
function (theFile) {
console.log("download complete: "+ theFile.toURI());
showLink(theFile.toURI( ));
setTimeout(function () {
checkConnection();
}, 50);
},
function (error) {< br /> console.log("download error source "+ error.source);
console.log("download error target" + error.target) ;
console.log("upload error code: "+ error.code);
});
},
fail);
},
fail);
After making the changes in the original question, I wanted to know if the file plugin part is normal, and started looking for the difference between my fileTransfer code and the provided example.
As a result, I did not do encodeURI() on my download source url (doh)
So the complete and valid code:
window.requestFileSystem (
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {
create: true,
exclusive: false
},
function gotFileEntry(fileEntry) {
var sPath = fileEntry.toURL().replace("dummy.html ", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
var DBuri = encodeURI("https://dl.dropbox.com/u/ 13253550/db02.xml");
fileTransfer.download(
DBuri,
sPath + "database.xml",
function (theFile) {
console.log("download complete: "+ theFile.toURI());
showLink(theFile.toURI());
setTimeout(function () {
checkConnection();
}, 50);< br />},
function (error) {
console.log("download error source "+ error.source);
console.log("download error target" + error.target);
console.log("upload error code: "+ error.code);
});
},
fail);
},
fail);
I recently upgraded my iOS Cordova project from 2.7.0 to 3.4.0.
< p>The file system access is broken after the upgrade. (Although it seems to work in the simulator? )
I received an error message stating that “the target file could not be created”. I googled it and considered changing my “full path” to “toURL()”, but to no avail. I’m really Don’t know what to try next?
This is my download code
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {
create: true,
exclusive: false
},
function gotFileEntry(fileEntry) {
var sPath = fileEntry.toURL().replace("dummy.html", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
fileTransfer.download(
"https://dl.dropbox.com/u/13253550/db02.xml",
sPath + "database.xml",
function (theFile) {
console.log("download complete: "+ theFile.toURI());
showLink(theFile.toURI( ));
setTimeout(function () {
checkConnection();
}, 50);
},
function (error) {< br /> console.log("download error source "+ error.source);
console.log("download error target" + error.target); console.log("upload error code: "+ error.code);
});
},
fail);
},
fail );
I found the file plugin (link) and fileTransfer plugin (link) documentation
In the original question After making the changes, I wanted to know if the file plugin part was normal, and started looking for the difference between my fileTransfer code and the provided example.
As a result, I didn’t find it on my download source url (doh) Do encodeURI()
So the complete, valid code:
window.requestFileSystem(
LocalFileSystem.PERSISTENT, 0,
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getFile(
"dummy.html", {
create: true,
exclusive: false
},
function gotFileEntry(fileEntry) {
var sPath = fileEntry.toURL().replace("dummy.html", "");
var fileTransfer = new FileTransfer();
fileEntry.remove();
var DBuri = encodeURI("https://dl.dropbox.com/u/13253550/db02.xml");
fileTransfer. download(
DBuri,
sPath + "database.xml",
function (theFile) {
console.log("download complete: "+ theFile.toURI ());
showLink(theFile.toURI());
setTimeout(function () {
checkConnection();
}, 50);
},
function (error) {
console. log("download error source "+ error.source);
console.log("download error target" + error.target);
console.log("upload error code: "+ error.code );
});
},
fail);
},
fail);