Wciąż próbuję uzyskać "kod błędu 5", próbując ustawić następujące prawo. Co chcę zrobić, to skopiować istniejący plik z zasobów w Androidzie do dostępnego miejsca na urządzeniu z Androidem, aby móc udostępnić je innym aplikacjom (takim jak poczta).Cordova: Nie można skopiować pliku na Androida za pomocą Cordova
Oto mój przykładowy kod:
window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;
var storagefolder = cordova.file.dataDirectory;
var storagefolderpointer;
console.log("storage folder: " + storagefolder);
// Check for support.
if (window.requestFileSystem) {
console.log("filesystem beschikbaar");
var getFSfail = function() {
console.log('Could not open filesystem');
};
var getFSsuccess = function(fs) {
var getDIRsuccess = function (dir) {
console.debug('Got dirhandle');
cachedir = dir;
fileurl = fs.root.fullPath + '/' + storagefolder;
storagefolderpointer = dir;
};
var getDIRfail = function() {
console.log('Could not open directory');
};
console.debug('Got fshandle');
FS = fs;
FS.root.getDirectory(storagefolder, {create:true,exclusive:false}, getDIRsuccess, getDIRfail);
};
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, getFSsuccess, getFSfail);
setTimeout(function() {
console.log("directory beschikbaar");
var suc = function(entry){
var goe = function(){
console.log("copy success");
};
var fou = function(){
console.log("copy NOT NOT success");
};
entry.copyTo(storagefolder, "vcard.vcf", goe, fou);
};
var fai = function(e){
console.log("fail getFile: " + e.code);
};
window.resolveLocalFileSystemURL(storagefolderpointer + "www/visitekaart/vcard.vcf", suc, fai);
}, 1000);
} else {
console.log("filesystem NOT NOT NOT available");
}
Jest związany z [ten numer] (https://github.com/driftyco/ng-cordova/issues/506)? Zobacz 10. komentarz – lifeisfoo
Czy próbowałeś korzystać z Filechooser? https://github.com/MaginSoft/MFileChooser –
Błąd jest "ENCODING_ERR", jak w dokumentach https://github.com/apache/cordova-plugin-file, proszę podać go w pytaniu, które może być istotne. –