Hello,
I get a strange behavior when I try to read file attributes.
The following method gets the URI from a filepicker.
I try to read file attributes thanks to
FilePath
FilePath.resolveNativePath
File.resolveDirectoryUrl
File.getFile
fileEntry.file
when on device I log tmpFile.size, It returns size of the file, on desktop, the file attribute is not even defined, so it blocks transpilation : what’s wrong here ?
is there an issue in FileEntry.file success callback definition ? typescript linting fails.
FileChooser.open()
.then(uri => {
console.log(“uri”, uri);
this.fileManagerService.readFile(uri);
})
.catch(e => console.log(e));
###################################################
readFile(uri:string): void {
console.log("uri", uri);
FilePath.resolveNativePath(uri).then(natifUrl => {
let path = natifUrl.substring(0, natifUrl.lastIndexOf('/'));
let fileName = natifUrl.substring(natifUrl.lastIndexOf('/') + 1, natifUrl.length );
File.resolveDirectoryUrl(path) // readAsText
.then(directoryEntry=> {
File.getFile(directoryEntry, fileName, {} ) // readAsText
.then(fileEntry=> {
fileEntry.file(tmpFile=> {
console.log('tmpFile', tmpFile);
console.log('tmpFile.size', tmpFile.size);
}, ((error:FileError) => console.log(error)));
})
.catch(err=>{
console.log("lecture de contenu error01", err);
});
})
})
.catch(e => console.log(e));
}