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

Pass 'user_project' if set for blob downloads w/ 'mediaLink' set #3500

Merged
merged 2 commits into from
Jun 26, 2017
Merged

Pass 'user_project' if set for blob downloads w/ 'mediaLink' set #3500

merged 2 commits into from
Jun 26, 2017

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented Jun 13, 2017

Fixes an oversight in #3495: server-set mediaLink triggers a separate branch when computing download URL.

Toward #3474.

@tseaver tseaver 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 Jun 13, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jun 13, 2017
@tseaver tseaver changed the title Pass 'user_project' if set for blob downloas w/ 'mediaLink' set Pass 'user_project' if set for blob downloads w/ 'mediaLink' set Jun 13, 2017
@@ -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.

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.

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.

This comment was marked as spam.

This comment was marked as spam.

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.

This comment was marked as spam.

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

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@tseaver
Copy link
Contributor Author

tseaver commented Jun 19, 2017

@lukesneeringer, @dhermes OK to merge?

@tseaver tseaver merged commit dbdc6a6 into googleapis:master Jun 26, 2017
@tseaver tseaver deleted the 3474-storage-requester_pays-blob-media_link branch July 31, 2017 16:42
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 21, 2017
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
landrito pushed a commit to landrito/google-cloud-python that referenced this pull request Aug 22, 2017
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. cla: yes This human has signed the Contributor License Agreement. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants