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

628
Visualizações
Node.js - How to get remote audio file's duration?

I have a binaries storage bucket (in Firebase Storage) and I am implementing a node.js Cloud Function which gets an audio (audio/m4a or audio/caf), verifies it format and duration, and then associate its uri with a document in my database (or deletes the audio file if its duration is not valid).

Before creating the document in my database, I need to validate the audio file.

For downloading the files from the storage I am using this function:

exports.downloadBinaryFileFromUrl = function (fileUrl) {
  /* This function downloads a binary-encoded file from its URL and returns it */
  return axios
    .get(fileUrl, {
      responseType: "arraybuffer",
    })
    .then((res) => Buffer.from(res.data, "binary"))
    .catch((err) => {
      if (err.response) {
        /* 
          The request was made and the server responded with a status code
          that falls out of the range of 2xx
        */
        throw err.response.data;
      } else if (err.request) {
        // Client never received a response, or request never left
        throw err.request;
      } else {
        // Something happened in setting up the request that triggered an Error
        throw new Error(`Error: ${err.message}`);
      }
    });
};

Any ideas how to get the audio file's duration using Node.js?

over 4 years ago · Santiago Trujillo
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