Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
Angular Upload recorded audio in angular to firebase storgae

I am working on project where I need to record audio and allow user to stop when he is done recording. I want to upload this recorded audio to firebase storage. I am not sure how to do it.

I am sharing the stack blitz link where I have implemented the audio recorder functionality.

https://stackblitz.com/edit/angular-record-rtc-demo

I have created one download function like below

  _downloadFile(data: any, type: string, filename: string): any {
    const blob = new Blob([data], { type: type });
    const url = window.URL.createObjectURL(blob);
    //this.video.srcObject = stream;
    //const url = data;
    const anchor = document.createElement('a');
    anchor.download = filename;
    anchor.href = url;
    document.body.appendChild(anchor);
    anchor.click();
    document.body.removeChild(anchor);
  }

I have created the fucntion for uploading a file like below

  selectFile(event): void {
    this.isUploading = true
    this.percentage = 0
    const file = event.target.files[0];
    this.currentFileUpload = new FileUpload(file);
    const filePath = `voice`;
    const fileRef = this.storage.ref(filePath);
    const task = this.storage.upload(`voice`, file);
    task
      .snapshotChanges()
      .pipe(
        finalize(() => {
          this.downloadURL = fileRef.getDownloadURL();
          this.downloadURL.subscribe(url => {
            console.log(url)
            if (url) {
              this.isUploading = false
              this.fb = url;
            }
            this.addUrlToEditor(url)

            task.percentageChanges().subscribe(percentage => {
              this.percentage = Math.round(percentage);
              this.percentage = percentage
            })
          });
        })
      )
      .subscribe(url => {
        if (url) {
          this.selectedFiles = null;
        }
      });
  }

I am able to download the audio. But I also want to upload recorded audio to firebase storage and use that url for future refrence for downloading the audio and other stuff. Any help will be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use this.audioName and this.audioBlob :

const storage = getStorage(); // imported from firebase/storage
const storageRef:any = ref(storage, this.audioName);
uploadBytes(storageRef, this.audioBlob);

This solution assumes that you have already configured Firebase in your Angular Project.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda