Upload Progress — Request
coffeescript, node.js
Solution
I needed a handle on the upload progress for yet another project of mine.
What I found out is that you can poll the `request`'s `connection._bytesDispatched` property.
For example:
r = request.post url: "http://foo.com", body: fileAsBuffer
setInterval (-> console.log "Uploaded: #{r.req.connection._bytesDispatched}"), 250
Note: If you were piping to `r`, poll `r.req.connection.socket._bytesDispatched` instead.
Problem
I'm uploading a file using `Request`. ``` req = request.post url: "http://foo.com", body: fileAsBuffer, (err, res, body) -> console.log "Uploaded!" ``` How do I know how much data has actually been uploaded? Is there some event that I can subscribe to or is there a property of the `request` that I can poll? If none, what would be the best approach to upload data and know how much has been uploaded?