Skip to content
6 changes: 4 additions & 2 deletions google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
)

exc_contents = str(exc_info.exception)
Expand Down