Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

231
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda