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
fix(storage): anonymous credentials for private bucket #107
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3204edc
fix(storage): anonymous credentials for private bucket
HemangChothani 134066e
fix(storage): use API_BASE_URL for hostname
HemangChothani 85729b7
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani dbd74fa
fix(storage): nit
HemangChothani 1d1ae94
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani ec45809
fix(storage): fix system test
HemangChothani 95f12c4
Merge branch 'master' into storage_issue_102
frankyn 6cc573b
Merge branch 'master' into storage_issue_102
frankyn c293e2f
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani 0588395
Merge branch 'storage_issue_102' of https://github.com/q-logic/python…
HemangChothani 6e8213b
fix(storage): revert changes
HemangChothani dc32e92
Merge branch 'master' into storage_issue_102
frankyn File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ | |
from google.cloud.storage.batch import Batch | ||
from google.cloud.storage.bucket import Bucket | ||
from google.cloud.storage.blob import Blob | ||
from google.cloud.storage import blob | ||
from google.cloud.storage import bucket | ||
from google.cloud.storage.hmac_key import HMACKeyMetadata | ||
from google.cloud.storage.acl import BucketACL | ||
from google.cloud.storage.acl import DefaultObjectACL | ||
|
@@ -122,6 +124,7 @@ def __init__( | |
if client_options.api_endpoint: | ||
api_endpoint = client_options.api_endpoint | ||
kw_args["api_endpoint"] = api_endpoint | ||
_override_private_url_variables(api_endpoint) | ||
|
||
if no_project: | ||
self.project = None | ||
|
@@ -1056,3 +1059,14 @@ def _item_to_hmac_key_metadata(iterator, item): | |
metadata = HMACKeyMetadata(iterator.client) | ||
metadata._properties = item | ||
return metadata | ||
|
||
|
||
def _override_private_url_variables(api_endpoint): | ||
blob._DOWNLOAD_URL_TEMPLATE = api_endpoint + u"/download/storage/v1{path}?alt=media" | ||
blob._BASE_UPLOAD_TEMPLATE = ( | ||
api_endpoint + u"/upload/storage/v1{bucket_path}/o?uploadType=" | ||
) | ||
blob._MULTIPART_URL_TEMPLATE = blob._BASE_UPLOAD_TEMPLATE + u"multipart" | ||
blob._RESUMABLE_URL_TEMPLATE = blob._BASE_UPLOAD_TEMPLATE + u"resumable" | ||
blob._API_ACCESS_ENDPOINT = api_endpoint | ||
bucket._API_ACCESS_ENDPOINT = api_endpoint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These URLs are used for Signature based requests like Signed URLs. These can be left alone because the method has a way to update the hostname because they don't use the same API (Download and Upload use JSON while Signature requests use XML API). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together. I think the code needs to be refactored for maintainability but the this is a good start.
The URLs in URL Templates could be refactored to be pulled in from the client which is passed around the library.
For example:
python-storage/google/cloud/storage/blob.py
Line 1020 in a50cdd1
Could be updated to:
WDYT?