Hi, my scenario:
- i open a file with FileChooser.open
this.fileChooser.open({mime: 'image/*'})
.then(uri => {
//
})
.catch(e => {
});
the uri is = content://com.android.providers.media.documents/document/image%3A4084
- resolve Native Source Path with
this.filePath.resolveNativePath(self.importedImageUrl).then(sourcePath=> {
the sourcePath is = file:///storage/0815-0815/DCIM/Camera/20210131_124359.jpg
- resolve Native Destiny Path
this.filePath.resolveNativePath(self.file.dataDirectory).then(destinyPath=> {
the destinyPath is = file:///data/user/0/io.ionic.starter/files/
-
pop the file name from the sourcePath
My Variables are now
fromPath = file:///storage/0815-0815/DCIM/Camera/;
fromFile = 20210131_124359.jpg;
toPath = file:///data/user/0/io.ionic.starter/files/;
toFile = 20210131_124359.jpg; -
checking if all directories and files exists
const self = this;
self.file.checkDir('file:///storage/0815-0815/DCIM', 'Camera')
.then((result) => {
console.log('checkDir', 'CHECK_001: directory :from exists :' + result);
self.file.checkDir('file:///data/user/0/io.ionic.starter', 'files')
.then((result) => {
self.file.checkFile('file:///storage/0815-0815/DCIM/Camera/', '20210131_124359.jpg')
.then((result) => {
return resolve(true);
}, (error) => {
return reject('Source File does\'nt exists');
});
}, (error) => {
return reject('Destination Dir does\'nt exists');
});
}, (error) => {
return reject('Source Dir does\'nt exists');
});
everything is fine, everything exists
- want to copy the file to the destiny path
this.file.copyFile(fromPath, fromFile, toPath, toFile).then(
successTrue => {
console.log('success: ', successTrue);
debugger
},
errorMessage1 => {
console.log('error: ', errorMessage1);
debugger
})
i got an error: FileError {code: 1, message: “NOT_FOUND_ERR”}
- i check if i can list the files in the sourcePath by
this.file.listDir( 'file:///storage/0815-0815/DCIM/', 'Camera').then(
(listing) => {
console.log('listing: ', listing);
debugger;
}
).catch(
(error) => {
console.log('error: ', error);
debugger;
}
);
the listing = // empty array
How can this be? I Choose the file by FileChooser, check everything exists
and get this error {code: 1, message: “NOT_FOUND_ERR”}
Please help. I cant find threads here with a solution in my case
By the way, i can display the choosen file in my <ion-img [src]=“getTrustImg(importedImageUrl)”>