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

155
Visualizações
Uploaded gz file in Google Cloud is damaged

I need help in uploading the gzip file into gcs. I am using nest js and @google-cloud/storage package.

  @Post('/uploadFile')
  async uploadFile(@Req() req: Request, @Res() res: Response) {
    req.setEncoding('utf-8');
    req.on('data', (chunk) => {
      const storage = new Storage({ keyFilename: 'datastore.json' });
      const bucket = storage.bucket('bucket_name');
      let mimeType = req.headers.filetype;
      let file = req.headers.filename;
      const blob = bucket.file(file + '');
      let strOut = "";
      for (var i = 0; i < chunk.length; i++) {
          strOut += chunk[i].charCodeAt(0).toString(2);
      }
      blob.save(strOut, {
        metadata: {
          contentType: mimeType,
          contentEncoding: 'gzip'
        },
        resumable: false,
        gzip:true
      });
   });

I am facing an issue while downloading the data file got downloaded but shows damaged/corrupted may be i am uploading the .gz file wrong. I am streaming the .gz file like this

   fs.createReadStream("compressedData/" + names[i]).pipe(
        request.post(
          {
            headers: config.headers,
            url: "http://localhost:3000/uploadFile",
          },
          (err, res) => {
            if (err) throw err;
            console.log(res.body, config);
          }
        )
      );

here is my config from client side

   config = {
          headers: {
            filetype: "application/gzip",
            filename: "sitemap/test-upload/" + names[i],
            token: "sadjfbkjbkjvkjvkvkcvkjxsdnkn",
          },
        };

about 4 years ago · Juan Pablo Isaza
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