@@ -241,27 +241,6 @@ def iterator(self, prefix=None, delimiter=None, max_results=None,
241241
242242 return self ._iterator_class (self , extra_params = extra_params )
243243
244- def new_blob (self , blob ):
245- """Given path name (or Blob), return a :class:`Blob` object.
246-
247- This is really useful when you're not sure if you have a ``Blob``
248- instance or a string path name. Given either of those types, this
249- returns the corresponding ``Blob``.
250-
251- :type blob: string or :class:`gcloud.storage.blob.Blob`
252- :param blob: A path name or actual blob object.
253-
254- :rtype: :class:`gcloud.storage.blob.Blob`
255- :returns: A Blob object with the path provided.
256- """
257- if isinstance (blob , Blob ):
258- return blob
259-
260- if isinstance (blob , six .string_types ):
261- return Blob (bucket = self , name = blob )
262-
263- raise TypeError ('Invalid blob: %s' % blob )
264-
265244 def delete (self , force = False ):
266245 """Delete this bucket.
267246
@@ -379,12 +358,12 @@ def copy_blob(self, blob, destination_bucket, new_name=None):
379358 """
380359 if new_name is None :
381360 new_name = blob .name
382- new_blob = destination_bucket . new_blob ( new_name )
361+ new_blob = Blob ( bucket = destination_bucket , name = new_name )
383362 api_path = blob .path + '/copyTo' + new_blob .path
384363 self .connection .api_request (method = 'POST' , path = api_path )
385364 return new_blob
386365
387- def upload_file (self , filename , blob = None ):
366+ def upload_file (self , filename , blob_name = None ):
388367 """Shortcut method to upload a file into this bucket.
389368
390369 Use this method to quickly put a local file in Cloud Storage.
@@ -398,9 +377,8 @@ def upload_file(self, filename, blob=None):
398377 >>> print bucket.get_all_blobs()
399378 [<Blob: my-bucket, remote-text-file.txt>]
400379
401- If you don't provide a blob value, we will try to upload the file
402- using the local filename as the blob (**not** the complete
403- path)::
380+ If you don't provide a blob name, we will try to upload the file
381+ using the local filename (**not** the complete path)::
404382
405383 >>> from gcloud import storage
406384 >>> connection = storage.get_connection(project)
@@ -412,22 +390,22 @@ def upload_file(self, filename, blob=None):
412390 :type filename: string
413391 :param filename: Local path to the file you want to upload.
414392
415- :type blob : string or :class:`gcloud.storage.blob.Blob`
416- :param blob : The blob (either an object or a remote path) of where
417- to put the file. If this is blank, we will try to
418- upload the file to the root of the bucket with the
419- same name as on your local file system.
393+ :type blob_name : string
394+ :param blob_name : The name of the blob to upload the file to. If this
395+ is blank, we will try to upload the file to the root
396+ of the bucket with the same name as on your local
397+ file system.
420398
421399 :rtype: :class:`Blob`
422400 :returns: The updated Blob object.
423401 """
424- if blob is None :
425- blob = os .path .basename (filename )
426- blob = self . new_blob ( blob )
402+ if blob_name is None :
403+ blob_name = os .path .basename (filename )
404+ blob = Blob ( bucket = self , name = blob_name )
427405 blob .upload_from_filename (filename )
428406 return blob
429407
430- def upload_file_object (self , file_obj , blob = None ):
408+ def upload_file_object (self , file_obj , blob_name = None ):
431409 """Shortcut method to upload a file object into this bucket.
432410
433411 Use this method to quickly put a local file in Cloud Storage.
@@ -441,9 +419,8 @@ def upload_file_object(self, file_obj, blob=None):
441419 >>> print bucket.get_all_blobs()
442420 [<Blob: my-bucket, remote-text-file.txt>]
443421
444- If you don't provide a blob value, we will try to upload the file
445- using the local filename as the blob (**not** the complete
446- path)::
422+ If you don't provide a blob name, we will try to upload the file
423+ using the local filename (**not** the complete path)::
447424
448425 >>> from gcloud import storage
449426 >>> connection = storage.get_connection(project)
@@ -455,19 +432,18 @@ def upload_file_object(self, file_obj, blob=None):
455432 :type file_obj: file
456433 :param file_obj: A file handle open for reading.
457434
458- :type blob : string or :class:`gcloud.storage.blob.Blob`
459- :param blob : The blob (either an object or a remote path) of where
460- to put the file. If this is blank, we will try to
461- upload the file to the root of the bucket with the
462- same name as on your local file system.
435+ :type blob_name : string
436+ :param blob_name : The name of the blob to upload the file to. If this
437+ is blank, we will try to upload the file to the root
438+ of the bucket with the same name as on your local
439+ file system.
463440
464441 :rtype: :class:`Blob`
465442 :returns: The updated Blob object.
466443 """
467- if blob :
468- blob = self .new_blob (blob )
469- else :
470- blob = self .new_blob (os .path .basename (file_obj .name ))
444+ if blob_name is None :
445+ blob_name = os .path .basename (file_obj .name )
446+ blob = Blob (bucket = self , name = blob_name )
471447 blob .upload_from_file (file_obj )
472448 return blob
473449
0 commit comments