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

190
Vistas
Socket hang up Express and Nodejs

I am trying to upload a file to one of the folder in the sharefile so I am using their upload API method. I was able to compile a snippet to test whether the upload works but I keep getting socket hang up error. Can you guys please check the below code and let me know on what is it that I am doing wrong? And also if there is another way (easier or best practice) where I can upload a file

var url = ""+urlString;
var filePath = "D:/Analytics All Web Site Data Browser & OS 20161001-20170306.pdf";
var boundaryKey = Math.random().toString(16);

var r = request.post( {
  url: url,
  proxy: "http://localhost:3128"
}, function( err, res, data ) {
  console.log( "Finished uploading a file " + err + " :: " + res + " :: " + data );
});

r.setHeader('Content-Type', 'multipart/form-data; boundary="'+boundaryKey+'"');

r.write( 
  '--' + boundaryKey + '\r\n'
  + 'Content-Type: application/octet-stream\r\n' 
  + 'Content-Disposition: form-data; name="Analytics"; filename="Analytics All Web Site Data Browser & OS 20161001-20170306.pdf"\r\n'
);

fs.createReadStream('D:/Analytics All Web Site Data Browser & OS 20161001-20170306.pdf', { bufferSize: 1024 * 1024 })
  .pipe(r, { end: false })
  .on('end', function() {
    r.end('--' + boundaryKey + '--'); 
  });
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