Giter Site home page Giter Site logo

Comments (8)

william-silversmith avatar william-silversmith commented on September 22, 2024

Thank you Tres!

from python-storage.

tseaver avatar tseaver commented on September 22, 2024

@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:

def _update_blob_content_encoding(blob, response):
    if blob.content_encoding is None:  # latch
        blob.content_encoding = response.headers.get('Content-Encoding')

from python-storage.

tseaver avatar tseaver commented on September 22, 2024

If we don't use a callback, then the relevant headers to start with would seem to be:

  • Cache-Control -> Blob.cache_control
  • Content-Disposition -> Blob.content_disposition
  • Content-Encoding -> Blob.content_encoding
  • Content-Length -> Blob.size
  • Content-Type -> Blob.content_type
  • Etag -> Blob.etag
  • X-Goog-Generation: Blob.generation
  • X-Goog-Hash: Blob.crc32c
  • X-Goog-Metageneration: Blob.metageneration
  • X-Goog-Storage-Class: Blob.storage_class

from python-storage.

william-silversmith avatar william-silversmith commented on September 22, 2024

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!

from python-storage.

william-silversmith avatar william-silversmith commented on September 22, 2024

Any word on when this might drop? Thanks for your help!

from python-storage.

william-silversmith avatar william-silversmith commented on September 22, 2024

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

from python-storage.

william-silversmith avatar william-silversmith commented on September 22, 2024

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.

from python-storage.

william-silversmith avatar william-silversmith commented on September 22, 2024

Figured out the PR submission issue.

from python-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.