Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Upload captured audio to Firebase Storage

$
0
0

Hi community, I am trying to upload to Firebase Storage audio captured using MediaCapture, converting the MediaFile to blob, but when I read the file using readAsArrayBuffer or readAsDataUrl the buffer that returns is empty. I tried a lot of ways to do this but I didn’t solve it. Here is the newest code. Thanks!

    this.mediaCapture.captureAudio().then(res => {
      var date = new Date();
      try{
        let name = res[0].name;
        let path = res[0].fullPath.substr(0, res[0].fullPath.lastIndexOf('/'));
        this.file.resolveDirectoryUrl(path).then((resolvedPath: DirectoryEntry) => {
          this.file.readAsArrayBuffer(resolvedPath.nativeURL, name).then( (buffer:any) => {
            let blob = new Blob([buffer], {
              type: res[0].type,
            });
            this.angularFireStorage.ref('chats/'+ this.chat + '/users/' + this.user.uid + '/audio/' + date).put(blob);
          }).catch(error => {
            console.log(error);
          });
        });
      } catch(error){
        presentToast(error);
      }

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>