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

191
Vistas
Streaming files from server to electron/angular2 client using request library

I am creating a desktop application using angular2 and electron. This client needs to download zip files from a server using the request library.

To be able to download files is only the first step, The client application will also need to be able to push zip files to the server. Compared how easy this is using the examples below I dont understand what is blocking this.

To get the fs and path library to work in electron I had to do some workaround in the index.html. this workaround is currently working and I am able to create folders within my file system with fs:

 <script>
   window.fs = require("fs");
   window.path = require("path");
 </script>

Code

Server

const restify = require('restify');
const server = restify.createServer();
const fs = require('fs');

server.post('/download', function(req, res) {
  fs.createReadStream("C:\\test\\test.zip").pipe(res);
});

server.listen(1338, function() {
  console.log('server started up on port 1338');
});

Working Client

let request = require("request");
let path = require("path");
let fs = require("fs");

request.post("http://localhost:1338/download").on("response", (response) => {
    let zipLocation = path.join("/test", "response.zip");
    let writeStream = fs.createWriteStream(zipLocation);

    writeStream.on("finish", () => {
        console.log("finished");
    }).on("error", (err) => {
        console.log("err: ", err.message);
    });

    response.pipe(writeStream);
}).on("error", (err) => {
    console.log("req err: ", err.message);
});

But when I introduce this client code into the angular2 electron app. I get a error:

err:  Invalid non-string/buffer chunk

I have the request library included within my angular app as such:

import * as request from 'request';

This issue might be connected to the request library. in the response from there are no headers. But I am unable to say for sure

response.headers // is a empty object: {}

Can anyone tell me the reason for as why I am unable to stream files from the server to the file system running the electron app?

UPDATE:

After trying to implement file upload I got the same error:

Invalid non-string/buffer chunk
over 4 years ago · Santiago Trujillo
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