listDir = (path, dirName) => {
this.fileNavigator
.listDir(path, dirName)
.then(entries => {
this.items = entries;
})
.catch(this.handleError);
}```
I'm able to list all the directories but not the directories that contain pdf's
Please help me out on this. Thank You...!
I’m looping over the items in the html template but it will give us all the folders if the entries are folders and it will be the same for the pdf files as well. My requirement is not to render the folders that don’t contain pdf files. Please refer to the below html template code.
The items content will either be folders or pdf files if they are present in respective subsequent folders. I’m having a function to navigate between folders(GO down method for entering into the directory & GoUp method for navigating to the root directory from the inner ones.) - code is shown below:
I’m not able to loop through all the inner directories at once from one page (with root folder) so that I can list out all the directories that contain pdf and show them or hide them depending on the pdf files existence.
I’m doing it from the android device - folders & pdf files will be coming from the native device(Android & IOS - for now I’m doing it on android) using ionic native file plugin. Below is the doc URL
Later, I’ll upload the files to the server once I’ve the option to choose the pdf file after listing out the directories from the native device root directory
Ok, this is much clearer but for this you will have to dig to a very deep level to see if the PDF exists inside a folder or not, or do you want to check only the next sub level?
Yeah, you got it tight! I will need to check every possible folder that contains even a single pdf file and show the respective root folder at the top level in a single page. Any further ideas to move forward in terms of code tweaks??
I’ve tried your code but it’s currently returning null values with current folder children. And also I’m also getting file listing errors for the other inner directories and returning null.
File listing errors for inner directories should be because of permission issue I presume. Can you post what output did you get from my current code? Also, if child sub directories can’t be read due to whatever issue, then the response returned from the method will be incomplete anyway.
Please let me know if I’m doing any mistake and also I’m not able to understand where we are pushing the folders containing pdf’s to the this.folders??
We do it in this.folders = await listDirHelper(path,dirName);
Also, I can see that the path and dirName are not pointing to any folder beforehand when it’s passed to listDir = async (path, dirName). Why? Certainly, empty path without pointing to a folder can’t give you any results. You could manually give these methods a proper folder path and it’s name and see if it gives the correct results.