GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add support for JSON API headers and query string parameters · Issue #30 · googleapis/python-storage

This repository was archived by the owner on Mar 31, 2026. It is now read-only.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

Add support for JSON API headers and query string parameters #30

Copy link
Copy link
Closed
Closed
Add support for JSON API headers and query string parameters#30
Copy link
Labels
api: storageIssues related to the googleapis/python-storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Description

@mlhamel
mlhamel
opened on Jun 26, 2018
Issue body actions

Description

The XML-Api and the Json-API are supporting a large set of parameters as described at https://cloud.google.com/storage/docs/xml-api/reference-headers.

Into those parameters you can find very useful features like x-goog-metageneration which let you control how to deal with versions and also blocking rewriting of blobs in a bucket.

These API used to be available in the AppEngine library for google cloud storage as you can see at https://cloud.google.com/appengine/docs/standard/python/googlecloudstorageclient/functions#open

Proposition

Adds support for extended options on different operations like upload_from_string and delete, something like:

def upload_from_string(self, data, content_type='text/plain', client=None,
                           predefined_acl=None, options=None):

Which would like you pick and sets of options from https://cloud.google.com/storage/docs/xml-api/reference-headers

Activity

  1. tseaver commented on Jun 26, 2018

    @tseaver
    tseaver
    on Jun 26, 2018
    Contributor
    More actions

    Docs for the JSON API headers / query string parameters. Where they differ, we would be following the latter, because we never directly invoke the XML API (Blob.public_url and Blob.generate_signed_url create URLs against the XML API endpoint, but don't invoke them).

    Reacted by Mathieu Leduc-Hamel
  2. tseaver commented on Aug 7, 2018

    @tseaver
    tseaver
    on Aug 7, 2018
    Contributor
    More actions

    Of the "standard" HTTP headers, I can see that there might be a usecase for supplying:

    • Cache-Control (override default 3600 value; only supported for fetching blobs accessible to all anonymous users).
    • Range (download partial content)
    • If-Match / If-None-Match (check an ETag)

    AFAICT, the JSON API only supports one "extension" header which is not covered / superseded by existing google-cloud-storage usage:

    • X-HTTP-Method-Override (smuggle PATCH requests through obtuse firewalls)
  3. tseaver commented on Aug 7, 2018

    @tseaver
    tseaver
    on Aug 7, 2018
    Contributor
    More actions

    Of the the query string parameters supported by the JSON API, we might want to support:

    • prettyPrint (remove whitespace from JSON responses)
    • quotaUser (enforce per-user quotas from a server-side application even in cases when the user's IP address is unknown)
    • userIp (enforce per-user quotas when calling the API from a server-side application.)

    The others are ether superseded by the library, or are tied to deprecated authentication schemes / JSON-P.

  4. tseaver commented on May 24, 2019

    @tseaver
    tseaver
    on May 24, 2019
    Contributor
    More actions

    With the release of google-cloud-core 1.0.0, the Connection class now exposes an extra_headers property, which can be used to pass whatever additional headers are needed (but not on a per-request basis:

    client._connection.extra_headers['X-Goog-Foo'] = 'Bar'
    Reacted by Mathieu Leduc-Hamel
  5. mlhamel commented on May 24, 2019

    @mlhamel
    mlhamel
    on May 24, 2019
    Author
    More actions

    Thanks for the updates I'm guessing it means we can now close this issue.

  6. tseaver commented on May 24, 2019

    @tseaver
    tseaver
    on May 24, 2019
    Contributor
    More actions

    @mlhamel I don't think the new Connection.extra_headers support is exactly what this issue wanted: it is kind of an "always on" configuration, rather than one which takes effect per-request.

  7. crwilcox
    transferred this issue fromgoogleapis/google-cloud-pythonon Jan 31, 2020
  8. product-auto-label
    added
    api: storageIssues related to the googleapis/python-storage API.
    on Jan 31, 2020
  9. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Feb 3, 2020
  10. frankyn
    added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    and removed
    🚨This issue needs some love.
    triage meI really want to be triaged.
    on Feb 4, 2020
  11. tseaver
    changed the title [-]Storage: Missing support for HTTP Headers and Query String Parameters[/-] [+]Add support for JSON API geaders and query string parameters[/+] on Aug 17, 2020
  12. daniellehanks commented on Mar 16, 2021

    @daniellehanks
    daniellehanks
    on Mar 16, 2021
    Contributor
    More actions

    Any update on this? I stumbled upon this needing to specify an If-None-Match header. Basically my use case is my API is a thin layer over GCS (for storing profile images), and I only want to actually read the image data and serve it to the client if the actual content is different from their cache. They will specify an If-None-Match header to my API (as they won't know anything about GCS or generation numbers, kind of the point), so I just need to essentially pass this along to GCS. I don't want to either do the extra round tripping of reading the current file to check the etag and then use the generation number from that in a subsequent request, or not use the client library.

  13. daniellehanks commented on Mar 23, 2021

    @daniellehanks
    daniellehanks
    on Mar 23, 2021
    Contributor
    More actions

    @tseaver Are you still a good resource for this ticket? Is this ticket still a good place to request etag conditional headers support or should I open a new ticket?

  14. tseaver commented on May 24, 2021

    @tseaver
    tseaver
    on May 24, 2021
    Contributor
    More actions

    @daniellehanks Adding conditional support for If-Match / If-None-Match should be a separate feature request from this issue -- implementing it would touch tons of places (pretty much every method which already has if_generation_match / if_metageneration_match would ), and It would need design (how does the user ask for the test? Should it use the etag of the resource by default? etc.)

    This feature would need to be commissioned by the GCS DPE team.

    /cc @frankyn, @tritone, @andrewsg .

  15. tseaver
    changed the title [-]Add support for JSON API geaders and query string parameters[/-] [+]Add support for JSON API headers and query string parameters[/+] on May 24, 2021
  16. daniellehanks commented on May 25, 2021

    @daniellehanks
    daniellehanks
    on May 25, 2021
    Contributor
    More actions

    Thanks @tseaver. Opened #451.

  17. cojenco commented on Apr 8, 2025

    @cojenco
    cojenco
    on Apr 8, 2025
    Contributor
    More actions

    Done via #489 and #1121

  18. cojenco
    closed this as completedon Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storageIssues related to the googleapis/python-storage API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.