readAsArrayBuffer promise does not resolve

Has anybody had the same problem? Promise does not resolve, how to get array buffer in a different way on android, any hints please? : ]

@aquinaswuwua Did you try making it asynchronous like this way? (remember the async in the method)
const result = await readAsArrayBufferPromise();

And validate that it returns you exactly readAsArrayBufferPromise();

Thank you for the answer! This is what I have for now:
html file:

  <ion-button (click)="pickFile()">documents</ion-button>

page file:

  constructor(
    private file: File,
    private fileChooser: FileChooser,
    private filePath: FilePath,
    private fileOpener: FileOpener,
    private store: Store<fromDocuments.State>,
  ) {
  }

  pickFile() {
    this.fileChooser.open().then((fileuri) => {
      this.filePath.resolveNativePath(fileuri).then(resolvedNativePath => {
        this.file.resolveLocalFilesystemUrl(resolvedNativePath)
          .then((entry: FileEntry) => {
            (entry).file(file => this.readFile(entry));
          })
          .catch(err => {
          });

      });
    });
  }

  async readFile(file: FileEntry) {
    const path = file.nativeURL.substr(0, file.nativeURL.lastIndexOf('/') + 1);
    // testing if is possible to open a given file
    this.fileOpener.open(file.nativeURL, 'application/pdf')
      .then(() => alert('File is opened'))
      .catch(e => alert(`Error openening file ${JSON.stringify(e)}`));

    try {
      const buffer = await this.file.readAsArrayBuffer(path, file.name);
      alert('buffer');
      const fileBlob = new Blob([buffer], {type: 'application/pdf'});
    } catch (error) {
      alert(`Buffering failed ${JSON.stringify(error)}`)
    } finally {
      alert('finally');
    }
  }

despite that the fileOpener opens a file without any problems alert(‘buffer’) is never fired. Furthermore neither catch nor finally blocks are fired as well. I was using following tutorial:
https://devdactic.com/upload-ionic-files-firebase-storage/
any hints why it does not work?

@aquinaswuwua Why are you doing the open(); synchronous before reading the buffer?

Notice the .then(); it should also be an await:

this.fileOpener.open(file.nativeURL, 'application/pdf')
.then(() => alert('File is opened'))
.catch(e => alert(`Error openening file ${JSON.stringify(e)}`));

If not, comment on that extract and try again.

thank you for the answer! To be honest I was opening the file just to test whether path is correct etc. It works! The problem is with readAsArrayBuffer, even after commenting code you mentioned alert(‘buffer’) never fires which starts to drives me crazy :wink: next Friday I have a deadline for the project and I am completely stuck with the post method :confused: colleagues start to make fun at me :wink:

@aquinaswuwua Are you using Cordova or Capacitor as a base platform for you Ionic Project?