Skip to content

Commit

Permalink
companion: Remove fs stat and use bytesWritten as content length (#2683)
Browse files Browse the repository at this point in the history
  • Loading branch information
mejiaej authored Dec 8, 2020
1 parent d1d2404 commit f09de1a
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions packages/@uppy/companion/src/server/Uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,19 +490,10 @@ class Uploader {
this._onMultipartComplete(error, response, body, bytesUploaded)
})
} else {
fs.stat(this.path, (err, stats) => {
if (err) {
logger.error(err, 'upload.multipart.size.error')
this.emitError(err)
return
}

const fileSizeInBytes = stats.size
reqOptions.headers['content-length'] = fileSizeInBytes
reqOptions.body = file
httpRequest(reqOptions, (error, response, body) => {
this._onMultipartComplete(error, response, body, bytesUploaded)
})
reqOptions.headers['content-length'] = this.bytesWritten
reqOptions.body = file
httpRequest(reqOptions, (error, response, body) => {
this._onMultipartComplete(error, response, body, bytesUploaded)
})
}
}
Expand Down

0 comments on commit f09de1a

Please sign in to comment.