hackney icon indicating copy to clipboard operation
hackney copied to clipboard

Add async events for upload

Open avdi opened this issue 11 years ago • 4 comments

Currently, the async mode only generates events once the remote server responds. I'd like to be able to monitor the progress of a large upload using POST. This means generating events for the submission phase of the request as well as the response. At the very least, "chunk" events and an event for when the whole request has been transmitted (but before the response has been received). Is this a possibility?

avdi avatar Jan 01 '14 23:01 avdi

This is not that easy. The only real thing you can retrieve on sent is the number of bytes already processed. There are no guarantee that these bytes have already been sent by the system except if you're using the connection option {nodelay, true} which isn't recommended on all systems. Also on pure TCP connections hackney is using the sendfile(2) API.

I think the best way to do that would be having

  1. a way to retrieve the number of bytes sent, processed The first one could be done by exposing the socket/port info from Erlang. The second by adding some metadata in hackney
  2. optionally add a log system so you can subscribe to the events and eventually provide a progress.

Thoughts?

benoitc avatar Jan 02 '14 10:01 benoitc

That sounds reasonable, yeah. I just don't want to have it sit there for 30s without any clue as to how far it has gotten.

avdi avatar Jan 02 '14 15:01 avdi

This is exactly what I'm looking for as well. Currently I have no options as far as I know to give user feedback on their upload progress when they are uploading a (bunch of) file(s) in the (web)interface.

Thanks for considering this :)

Gerard.

smeevil avatar Jan 09 '16 08:01 smeevil

@smeevil i will provide the needed metrics for that

benoitc avatar Jan 25 '16 10:01 benoitc