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

245
Views
Crear archivo desde legible, agregar archivo y tubería a escritura

El objetivo es recibir un archivo del cliente, agregar un archivo y cargarlo en Cloud Storage sin crear un archivo temporal. Tanto el cliente como el servidor utilizan la biblioteca del archiver . El problema con el siguiente código es que file2.txt no se agrega al archivo.

Cliente:

 import archiver from "archiver"; const archive = archiver("zip", { zlib: { level: 9 }, }); archive.append("string cheese!", { name: "file1.txt" }); await fetch(`/archive`, { method: "POST", body: archive, });

Servidor:

 import archiver from "archiver"; import { Storage } from "@google-cloud/storage"; import { Router } from "express"; const router = Router(); const storage = new Storage(); router.post("/", (req, res) => { const archive = archiver("zip", { zlib: { level: 9 }, }); const cloudFile = storage.bucket("archives").file("archive.zip"); req.pipe(archive, { end: false, }); archive.pipe(cloudFile.createWriteStream()); req.on("end", async () => { archive.append("string cheese!", { name: "file2.txt" }); archive.finalize(); archive.end(); }); });
over 4 years ago · Santiago Trujillo
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!