From f7d155412e6b09a771c627910083f3086163cdd4 Mon Sep 17 00:00:00 2001 From: Michael Jedich Date: Sun, 4 Mar 2018 15:22:01 +0100 Subject: [PATCH] https://github.com/danwrong/restler/issues/250 --- lib/multipartform.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/multipartform.js b/lib/multipartform.js index 48002ae..6fd44c9 100644 --- a/lib/multipartform.js +++ b/lib/multipartform.js @@ -108,9 +108,9 @@ Part.prototype = { //Now write out the body of the Part if (this.value instanceof File) { - fs.open(this.value.path, 'r+', function (err, fd) { + fs.openSync(this.value.path, 'r+', function (err, fd) { var stats = fs.fstatSync(fd); - var bufferSize = stats.size + var bufferSize = stats.size; if (err) throw err; var chunkSize = 512; var position = 0; @@ -129,7 +129,9 @@ Part.prototype = { else { stream.write("\r\n"); callback(); - fs.close(fd); + fs.close(fd, function(err) { + callback(err); + }); } }); })(); // reader()