Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Expose preconditions via the google-cloud-storage API #4490

Closed
brennie opened this issue Nov 29, 2017 · 4 comments
Closed

Storage: Expose preconditions via the google-cloud-storage API #4490

brennie opened this issue Nov 29, 2017 · 4 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@brennie
Copy link

brennie commented Nov 29, 2017

It would be very useful if google-cloud-storage exposed a way to set preconditions on upload. I am currently hacking around this by replacing google.cloud.storage.blob. _MULTIPART_URL_TEMPLATE and google.cloud.storage.blob._RESUMABLE_URL_TEMPLATE with versions that have the precondition I require, e.g.

from google.cloud import storage as gcs

gcs.blob._MULTIPART_URL_TEMPLATE = (
    f'{gcs.blob._MULTIPART_URL_TEMPLATE}&ifGenerationMatch=0'
)
gcs.blob._RESUMABLE_URL_TEMPLATE = (
    f'{gcs.blob._RESUMABLE_URL_TEMPLATE}&ifGenerationMatch=0'
)

Luckily I am only uploading blobs that I do not want to exist beforehand. It would be great if there were a way to programmatically do this, but I could not find anything after pouring over the documentation and source code.

I hope you'll implement this in a future version.

Thanks for your time!

@chemelnucfin chemelnucfin added api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Nov 29, 2017
@dhermes
Copy link
Contributor

dhermes commented Nov 29, 2017

Thanks for the request @brennie this is definitely something worth adding!

@bits01
Copy link

bits01 commented Dec 7, 2017

Thanks for posting the hack, very useful until the feature is implemented.

@tseaver
Copy link
Contributor

tseaver commented Jun 20, 2018

For uploads, there are three cases:

  • Do not pass the ifGenerationMatch query string parameter (this would need to be the default for backward-compatibility)
  • Pass &ifGenerationMatch=0 if there is no generation set on the blob resource.
  • Pass &ifGenerationMatch=<current-generation> if there is a generation set.

After a chat with @frankyn, I'm closing this issue: he will be working with the GCS team to prioritize more complete precondition support in our feature backlog.

@amygdala
Copy link
Contributor

Is there an ETA for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

7 participants