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

234
Visualizações
How to pipe the res file to google cloud storage stream to save file on gs?
import {Storage} from "@google-cloud/storage";
this.post(
  "/webhook",
  async (req, res) => {
    const storage = new Storage({/** google credential filename */ });
    const clientBucket = storage.bucket(/** bucket name */);

      // Create a reference to a file object
      const fileName = `${moment().format("YYYYMMDDHHmmss")}.tar.gz`;
      const file = clientBucket.file(fileName);
      req.pipe(file.createWriteStream());
      req.on("end", () => {
        // have to update in db that file has been uploaded
      });
   })

Running this code on my local node server which is not uploading the file on gs storage. This is the post-call in this. I am receiving the stream data in req. I am not sure what I am doing wrong. If I write the req.pipe() in a local folder, it creates a file. Please note I am not getting any errors in the terminal.

Post call request headers : enter image description here

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

0

You need to write JSON file to /tmp directory using fs.createWriteStream and then pipe file from /tmp to Storage using Storage API.

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