Skip to content

Commit 7fb81c5

Browse files
committed
Removing upload boolean from JSONConnection.
1 parent 39101c6 commit 7fb81c5

4 files changed

Lines changed: 11 additions & 27 deletions

File tree

gcloud/connection.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ class JSONConnection(Connection):
119119
"""A template for the URL of a particular API call."""
120120

121121
@classmethod
122-
def build_api_url(cls, path, query_params=None, api_base_url=None,
123-
api_version=None, upload=False):
122+
def build_api_url(cls, path, query_params=None,
123+
api_base_url=None, api_version=None):
124124
"""Construct an API url given a few components, some optional.
125125
126126
Typically, you shouldn't need to use this method.
@@ -141,15 +141,10 @@ def build_api_url(cls, path, query_params=None, api_base_url=None,
141141
Typically you shouldn't provide this and instead
142142
use the default for the library.
143143
144-
:type upload: boolean
145-
:param upload: True if the URL is for uploading purposes.
146-
147144
:rtype: string
148145
:returns: The URL assembled from the pieces provided.
149146
"""
150147
api_base_url = api_base_url or cls.API_BASE_URL
151-
if upload:
152-
api_base_url += '/upload'
153148

154149
url = cls.API_URL_TEMPLATE.format(
155150
api_base_url=(api_base_url or cls.API_BASE_URL),

gcloud/storage/blob.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,19 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
334334
upload_config = _UploadConfig()
335335

336336
# Temporary URL, until we know simple vs. resumable.
337-
upload_url = conn.build_api_url(
338-
path=self.bucket.path + '/o', upload=True)
337+
base_url = conn.API_BASE_URL + '/upload'
338+
upload_url = conn.build_api_url(api_base_url=base_url,
339+
path=self.bucket.path + '/o')
339340

340341
# Use apitools 'Upload' facility.
341342
request = http_wrapper.Request(upload_url, 'POST', headers)
342343

343344
upload.ConfigureRequest(upload_config, request, url_builder)
344345
query_params = url_builder.query_params
345-
request.url = conn.build_api_url(path=self.bucket.path + '/o',
346-
query_params=query_params,
347-
upload=True)
346+
base_url = conn.API_BASE_URL + '/upload'
347+
request.url = conn.build_api_url(api_base_url=base_url,
348+
path=self.bucket.path + '/o',
349+
query_params=query_params)
348350
upload.InitializeUpload(request, conn.http)
349351

350352
# Should we be passing callbacks through from caller? We can't

gcloud/storage/test_blob.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,13 +1014,11 @@ def api_request(self, **kw):
10141014
return result
10151015

10161016
def build_api_url(self, path, query_params=None,
1017-
api_base_url=API_BASE_URL, upload=False):
1017+
api_base_url=API_BASE_URL):
10181018
from six.moves.urllib.parse import urlencode
10191019
from six.moves.urllib.parse import urlsplit
10201020
from six.moves.urllib.parse import urlunsplit
1021-
# mimic the build_api_url interface, but avoid unused param and
1022-
# missed coverage errors
1023-
upload = not upload # pragma NO COVER
1021+
# Mimic the build_api_url interface.
10241022
qs = urlencode(query_params or {})
10251023
scheme, netloc, _, _, _ = urlsplit(api_base_url)
10261024
return urlunsplit((scheme, netloc, path, qs, ''))

gcloud/storage/test_connection.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,6 @@ def test_build_api_url_w_extra_query_params(self):
7878
parms = dict(parse_qsl(qs))
7979
self.assertEqual(parms['bar'], 'baz')
8080

81-
def test_build_api_url_w_upload(self):
82-
conn = self._makeOne()
83-
URI = '/'.join([
84-
conn.API_BASE_URL,
85-
'upload',
86-
'storage',
87-
conn.API_VERSION,
88-
'foo',
89-
])
90-
self.assertEqual(conn.build_api_url('/foo', upload=True), URI)
91-
9281
def test__make_request_no_data_no_content_type_no_headers(self):
9382
conn = self._makeOne()
9483
URI = 'http://example.com/test'

0 commit comments

Comments
 (0)