You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Storage: Capture relevant headers to blob properties during download #24
@william-silversmith notes that even with raw_download enabled, he is unable to detect the content_type of a downloaded blob without performing an additional reload request, which is prohibitive for his usecase at scale. E.g.:
@william-silversmith The headers needed to do this task are buried several layers deep. I'm wondering if a better solution than trying to guess which ones to map onto the blob's properties, we might be better off designing for your usecase by supplying a response_callback argument to the Blob.download_* methods:
The callback would take the blob instance and a requests.Response object as its arguments.
For non-chunked downloads, the callback would be called once; chunked downloads would call it once per chunk.
An example callback implementation for your usecase might be something like:
I almost never need more exotic headers than the ones you listed. If it's easier to only expose those headers, that's fine with me. If you want to go for a more general solution, I am fine with a (synchronous) callback. Thanks again!
Hi Tres, I've made some changes to my own branch of this repo and they seem to work. I tried making a PR but the button was greyed out. Here's a link to the changes in case y'all are interested. In the mean time, I'll direct my repos to use the forked version.
Activity
william-silversmith commentedon Nov 13, 2019
Thank you Tres!
tseaver commentedon Nov 13, 2019
@william-silversmith The headers needed to do this task are buried several layers deep. I'm wondering if a better solution than trying to guess which ones to map onto the blob's properties, we might be better off designing for your usecase by supplying a
response_callbackargument to theBlob.download_*methods:requests.Responseobject as its arguments.An example callback implementation for your usecase might be something like:
tseaver commentedon Nov 13, 2019
If we don't use a callback, then the relevant headers to start with would seem to be:
Cache-Control->Blob.cache_controlContent-Disposition->Blob.content_dispositionContent-Encoding->Blob.content_encodingContent-Length->Blob.sizeContent-Type->Blob.content_typeEtag->Blob.etagX-Goog-Generation:Blob.generationX-Goog-Hash:Blob.crc32cX-Goog-Metageneration:Blob.metagenerationX-Goog-Storage-Class:Blob.storage_classwilliam-silversmith commentedon Nov 14, 2019
I almost never need more exotic headers than the ones you listed. If it's easier to only expose those headers, that's fine with me. If you want to go for a more general solution, I am fine with a (synchronous) callback. Thanks again!
william-silversmith commentedon Jan 27, 2020
Any word on when this might drop? Thanks for your help!
william-silversmith commentedon Jul 14, 2020
Hi Tres, I've made some changes to my own branch of this repo and they seem to work. I tried making a PR but the button was greyed out. Here's a link to the changes in case y'all are interested. In the mean time, I'll direct my repos to use the forked version.
master...seung-lab:master
william-silversmith commentedon Jul 15, 2020
Unfortunately, it seems PyPI won't let me use a direct reference to github. It would be extremely convenient if some version of this could get merged.
william-silversmith commentedon Jul 15, 2020
Figured out the PR submission issue.
feat(blob.py): auto-populate standard headers for non-chunked downloa…
feat(blob.py): auto-populate standard headers for non-chunked downloa…
feat(blob.py): auto-populate standard headers for non-chunked downloa…