@@ -271,7 +271,8 @@ def download_as_string(self):
271271 return string_buffer .getvalue ()
272272
273273 def upload_from_file (self , file_obj , rewind = False , size = None ,
274- content_type = None , num_retries = 6 ):
274+ content_type = None , num_retries = 6 ,
275+ upload_chunk_size = None ):
275276 """Upload the contents of this blob from a file-like object.
276277
277278 .. note::
@@ -285,6 +286,11 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
285286 `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
286287 API documents for details.
287288
289+ The current ``Blob``'s chunk size is not used by default. Default
290+ behavior is instead to attempt uploading the entire object. See
291+ https://github.com/GoogleCloudPlatform/gcloud-python/issues/546
292+ for more details.
293+
288294 :type file_obj: file
289295 :param file_obj: A file handle open for reading.
290296
@@ -296,6 +302,15 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
296302 :param size: The number of bytes to read from the file handle.
297303 If not provided, we'll try to guess the size using
298304 :func:`os.fstat`
305+
306+ :type content_type: string or ``NoneType``
307+ :param content_type: Optional content type of uploaded content.
308+
309+ :type num_retries: int
310+ :param num_retries: Optional number of retries. Defaults to 6.
311+
312+ :type upload_chunk_size: int or ``NoneType``
313+ :param upload_chunk_size: Optional size of chunks to upload with.
299314 """
300315 # Rewind the file if desired.
301316 if rewind :
@@ -313,7 +328,7 @@ def upload_from_file(self, file_obj, rewind=False, size=None,
313328 upload = transfer .Upload (file_obj ,
314329 content_type or 'application/unknown' ,
315330 total_bytes , auto_transfer = False ,
316- chunksize = self . CHUNK_SIZE )
331+ chunksize = upload_chunk_size )
317332
318333 url_builder = _UrlBuilder (bucket_name = self .bucket .name ,
319334 object_name = self .name )
@@ -611,7 +626,7 @@ def updated(self):
611626
612627
613628class _UploadConfig (object ):
614- """ Faux message FBO apitools' 'ConfigureRequest'.
629+ """Faux message for benefit of apitools' 'ConfigureRequest'.
615630
616631 Values extracted from apitools
617632 'samples/storage_sample/storage/storage_v1_client.py'
@@ -625,7 +640,7 @@ class _UploadConfig(object):
625640
626641
627642class _UrlBuilder (object ):
628- """Faux builder FBO apitools' 'ConfigureRequest'"""
643+ """Faux builder for benefit of apitools' 'ConfigureRequest'"""
629644 def __init__ (self , bucket_name , object_name ):
630645 self .query_params = {'name' : object_name }
631646 self ._bucket_name = bucket_name
0 commit comments