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

fix: from_string method of blob and bucket class #290

Merged
merged 7 commits into from Nov 11, 2020
6 changes: 4 additions & 2 deletions google/cloud/storage/blob.py
Expand Up @@ -1598,6 +1598,7 @@ def _do_multipart_upload(
:raises: :exc:`ValueError` if ``size`` is not :data:`None` but the
``stream`` has fewer than ``size`` bytes remaining.
"""
client = self._require_client(client)
if size is None:
data = stream.read()
else:
Expand All @@ -1611,7 +1612,7 @@ def _do_multipart_upload(
headers, object_metadata, content_type = info

base_url = _MULTIPART_URL_TEMPLATE.format(
hostname=self.client._connection.API_BASE_URL, bucket_path=self.bucket.path
hostname=client._connection.API_BASE_URL, bucket_path=self.bucket.path
)
name_value_pairs = []

Expand Down Expand Up @@ -1768,6 +1769,7 @@ def _initiate_resumable_upload(
that was created
* The ``transport`` used to initiate the upload.
"""
client = self._require_client(client)
if chunk_size is None:
chunk_size = self.chunk_size
if chunk_size is None:
Expand All @@ -1780,7 +1782,7 @@ def _initiate_resumable_upload(
headers.update(extra_headers)

base_url = _RESUMABLE_URL_TEMPLATE.format(
hostname=self.client._connection.API_BASE_URL, bucket_path=self.bucket.path
hostname=client._connection.API_BASE_URL, bucket_path=self.bucket.path
)
name_value_pairs = []

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_blob.py
Expand Up @@ -1974,6 +1974,7 @@ def test__do_multipart_upload_with_generation_not_match(self, mock_get_boundary)

def test__do_multipart_upload_bad_size(self):
blob = self._make_one(u"blob-name", bucket=None)
client = mock.Mock()

data = b"data here hear hier"
stream = io.BytesIO(data)
Expand All @@ -1982,7 +1983,7 @@ def test__do_multipart_upload_bad_size(self):

with self.assertRaises(ValueError) as exc_info:
blob._do_multipart_upload(
None, stream, None, size, None, None, None, None, None, None
client, stream, None, size, None, None, None, None, None, None
)
tseaver marked this conversation as resolved.
Show resolved Hide resolved

exc_contents = str(exc_info.exception)
Expand Down