I use the following code to explore the file system in an ionic App the save files to the device for uploading latter.
import { Component, ElementRef, ViewChild } from '@angular/core';
import { Filesystem, Directory } from '@capacitor/filesystem';
import write_blob from 'capacitor-blob-writer';
export class QuestionPhotosPage {
@ViewChild('filepicker') uploader: ElementRef;
addFile() {
this.uploader.nativeElement.click();
console.log("click open file explorer");
}
async fileSelected($event) {
console.log("$event", $event)
const selected = $event.target.files[0];
let fileName = this.createFileNameAlt(selected.name)
await write_blob({
directory: Directory.Documents,
path: `${this.FILE_DIR}/${fileName}`,
blob: selected,
fast_mode: true,
recursive: true,
on_fallback(error) { console.error(error) }
})
}
I was wondering if there is away to filter the addFile() to only show folders and pdf documents?