-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pass 'user_project' if set for blob downloads w/ 'mediaLink' set #3500
Pass 'user_project' if set for blob downloads w/ 'mediaLink' set #3500
Conversation
storage/google/cloud/storage/blob.py
Outdated
@@ -404,14 +408,22 @@ def _get_download_url(self): | |||
:returns: The download URL for the current blob. | |||
""" | |||
if self.media_link is None: | |||
download_url = _DOWNLOAD_URL_TEMPLATE.format(path=self.path) | |||
base_url = _DOWNLOAD_URL_TEMPLATE.format(path=self.path) | |||
scheme, netloc, path, query, frag = urlsplit(base_url) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
else: | ||
return self.media_link | ||
scheme, netloc, path, query, frag = urlsplit(self.media_link) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
query = parse_qsl(query) | ||
|
||
if self.user_project is not None: | ||
query.append(('userProject', self.user_project)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
storage/google/cloud/storage/blob.py
Outdated
scheme, netloc, path, query, frag = urlsplit(base_url) | ||
query = parse_qsl(query) | ||
# Only add `generation' for synthesized URLs: 'mediaLink' from | ||
# server presumably already encodes it. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -366,7 +366,7 @@ def test__make_transport(self, fake_session_factory): | |||
|
|||
def test__get_download_url_with_media_link(self): | |||
blob_name = 'something.txt' | |||
bucket = mock.Mock(spec=[]) | |||
bucket = _Bucket(name='IRRELEVANT') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@lukesneeringer, @dhermes OK to merge? |
Fixes an oversight in #3495: server-set
mediaLink
triggers a separate branch when computing download URL.Toward #3474.