@@ -60,16 +60,22 @@ Create a new bucket
6060 >> > from gcloud import storage
6161 >> > new_bucket = storage.create_bucket(bucket_name)
6262
63- if you desire to be declarative, you may pass in a connection to
64- override the default
63+ .. warning ::
64+ If the bucket already exists, this method will throw an exception
65+ corresponding to the `409 conflict `_ status code in the response.
66+
67+ If you desire to be declarative, you may pass in a connection and a project
68+ to override the defaults
6569
6670.. code-block :: python
6771
68- >> > new_bucket = storage.create_bucket(bucket_name, connection = connection)
72+ >> > new_bucket = storage.create_bucket(bucket_name, connection = connection,
73+ ... project = project)
6974
7075 .. note ::
7176 All methods in the ``storage `` package accept ``connection `` as an optional
72- parameter.
77+ parameter. (Only ``create_bucket `` and ``list_buckets `` accept ``project ``
78+ to override the default.)
7379
7480Retrieve an existing bucket
7581
@@ -177,7 +183,7 @@ this can be addressed by using the ``force`` keyword
177183 >>> storage.delete_bucket(bucket_name, force = True )
178184
179185Even using ``force=True `` will fail if the bucket contains more than 256
180- blobs. In this case, the blobs should be deleted manually first .
186+ blobs. In this case, delete the blobs manually before deleting the bucket .
181187
182188.. _409 conflict : http://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_Error
183189
@@ -649,19 +655,40 @@ uploading:
649655 >> > blob.content_type = ' application/zip'
650656 >> > blob.upload_from_string(' foo' )
651657
652- To upload instead from a file
658+ To upload instead from a file-like object
659+
660+ .. code-block :: python
661+
662+ >> > blob.upload_from_stream(file_object)
663+
664+ To upload directly from a file
653665
654666 .. code-block :: python
655667
656668 >> > blob.upload_from_filename(' /path/on/local/machine.file' )
657669
670+ This is roughly equivalent to
671+
672+ .. code-block :: python
673+
674+ >> > with open (' /path/on/local/machine.file' , ' w' ) as file_object:
675+ ... blob.upload_from_stream(file_object)
676+
677+ with some extra behavior to set local file properties.
678+
658679To download blob data into a string
659680
660681 .. code-block :: python
661682
662683 >> > blob_contents = blob.download_as_string()
663684
664- To download instead to a file
685+ To download instead to a file-like object
686+
687+ .. code-block :: python
688+
689+ >> > blob.download_to_stream(file_object)
690+
691+ To download directly to a file
665692
666693 .. code-block :: python
667694
0 commit comments