I want to display all types of files in separate tabs like Videos, Pdfs, Music etc. I have tried using the listDir method of native-file plugin… But to get all files grouped I have to recursively visit each folder which takes too long and affects the performance too as the storage of a regular device is pretty large these days (>=128GB). Is there any other ways to do so?
Here is my code
groupFiles() {
return new Promise((resolve, reject) => {
this.file.listDir(this.file.externalRootDirectory, '').then((data: Array<DirectoryEntry>) => {
data.forEach(e => {
if (e.isDirectory) {
this.promises.push(this.recurseGroup(e));
} else if (e.isFile) {
this.allGroup.push(e);
}
});
resolve();
});
});
}
recurseGroup(entry: DirectoryEntry) {
console.log('called');
return new Promise((resolve, reject) => {
this.file.listDir(entry.nativeURL, '').then((data: Array<DirectoryEntry>) => {
data.forEach(e => {
if (e.isDirectory && e.name !== '.' && e.name !== '..') {
this.promises.push(this.recurseGroup(e));
} else if (e.isFile) {
this.allGroup.push(e);
}
});
resolve();
});
});
}