Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

238
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!