s3transfer icon indicating copy to clipboard operation
s3transfer copied to clipboard

Allow to capture head object (metadata) in download file

Open wimglenn opened this issue 7 years ago • 3 comments

Want to download an object along with its associated metadata, and I imagine that's a common use-case. The download_file method already issues a head request in order to get content length and decide whether to use multipart or not. Could you provide some kind of public API to capture this head_object so we don't need to make an extra request (slow, wasteful, and adds more race conditions)? I'm not sure the best interface, maybe just use the return value of download_file (currently just returns None) or add container/callback as optional argument.

wimglenn avatar Mar 29 '18 00:03 wimglenn

Seems like a reasonable idea to me.

stealthycoin avatar Apr 09 '18 23:04 stealthycoin

I have a very similar feature request. I avoid the head request by passing a subscriber and calling provide_transfer_size - but I still need to get the response metadata, which could come from either the head or the get request. In case of multipart get, it gets a little weird since there will be multiple responses with (hopefully) identical metadata - but I think it's fair to expect the caller to deal with that.

I'm thinking of adding an on_start (or on_response?) to BaseSubscriber, and calling it from here. I'll send out a PR once I get something working.

dimaryaz avatar Oct 23 '18 20:10 dimaryaz

Sent out a PR: #113

dimaryaz avatar Oct 24 '18 22:10 dimaryaz