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

120
Views
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 + '--'); 
  });
about 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!