You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Vito Macchia (JIRA)" <ji...@apache.org> on 2016/03/06 12:51:40 UTC
[jira] [Created] (CB-10798) Cannot create folder into
cordova.file.externalRootDirectory on Android 6.x Marshmallow
Vito Macchia created CB-10798:
---------------------------------
Summary: Cannot create folder into cordova.file.externalRootDirectory on Android 6.x Marshmallow
Key: CB-10798
URL: https://issues.apache.org/jira/browse/CB-10798
Project: Apache Cordova
Issue Type: Bug
Components: Plugin File
Affects Versions: 4.1.1
Environment: Android 6.0.1 (Nexus 9 and other 6.x devices), Cordova cli 6.0.0, Android platform 5.1.0
Reporter: Vito Macchia
Cannot create folder into cordova.file.externalRootDirectory on Android 6.x Marshmallow. It always returns encording error (12), while on Android 5.x (Lollipop) the same code works fine.
On Marshmallow devices I can succesfully create folders only into cordova.file.externalDataDirectory.
No matter the value of preference AndroidPersistentFileLocation or AndroidExtraFilesystems.
Code (ES6, sorry)
function errorCode(e) {
var msg = '';
switch (e.code) {
case FileError.ABORT_ERR:
msg = 'ABORT_ERR';
break;
case FileError.ENCODING_ERR:
msg = 'ENCODING_ERR';
break;
case FileError.NOT_READABLE_ERR:
msg = 'NOT_READABLE_ERR';
break;
case FileError.PATH_EXISTS_ERR:
msg = 'PATH_EXISTS_ERR';
break;
case FileError.QUOTA_EXCEEDED_ERR:
msg = 'QUOTA_EXCEEDED_ERR';
break;
case FileError.NOT_FOUND_ERR:
msg = 'NOT_FOUND_ERR';
break;
case FileError.SECURITY_ERR:
msg = 'SECURITY_ERR';
break;
case FileError.INVALID_MODIFICATION_ERR:
msg = 'INVALID_MODIFICATION_ERR';
break;
case FileError.INVALID_STATE_ERR:
msg = 'INVALID_STATE_ERR';
break;
default:
msg = 'Unknown Error';
break;
};
console.log('Error: ' + msg, "CODE", e);
return msg;
}
const STATIC_CONTENT_DIR = 'MY_Folder';
function createDirectory(startDirectory = cordova.file.externalRootDirectory) {
return new WinJS.Promise(function(success, fail) {
window.resolveLocalFileSystemURL(startDirectory, function(directory) {
console.log("FS ROOT", directory);
function fileGetDir(path, cb) {
console.log("*** PATH", path);
var fnGetOrCreateDir = function(p, de) {
var entry = p.shift();
console.log("PATH", path);
if (entry) {
de.getDirectory(entry, {
create: true,
exclusive: false
}, function(dirEntry) {
console.log("CR", dirEntry);
fnGetOrCreateDir(p, dirEntry);
}, fileFSError);
} else
if (cb) cb(de);
};
if (path) {
var arPath = path.split("/");
fnGetOrCreateDir(arPath, directory.filesystem.root);
} else {
if (cb) cb(directory);
}
}
fileGetDir(STATIC_CONTENT_DIR, onSuccess);
}, fileFSError);
function fileFSError(e) {
console.log(e.code);
try {
console.log("fileFSError: " + JSON.stringify(e) + errorCode(e));
fail(e);
} catch (err) {
fail(err);
}
}
function onSuccess(dirEntry) {
console.log(dirEntry.fullPath);
success(dirEntry.fullPath)
}
});
}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org