@@ -4,7 +4,7 @@ Getting started with Cloud Storage
44This tutorial focuses on using ``gcloud `` to access
55Google Cloud Storage.
66We'll go through the basic concepts,
7- how to operate on buckets and keys ,
7+ how to operate on buckets and blobs ,
88and how to handle access control,
99among other things.
1010
@@ -114,32 +114,31 @@ so if you want to group data into "directories",
114114you can do that.
115115
116116The fundamental container for a file in Cloud Storage
117- is called an Object,
118- however ``gcloud `` uses the term ``Key ``
119- to avoid confusion between ``object `` and ``Object ``.
117+ is called an Object, however ``gcloud `` uses the term ``Blob ``
118+ to avoid confusion with the Python built-in ``object ``.
120119
121120If you want to set some data,
122- you just create a ``Key `` inside your bucket
123- and store your data inside the key ::
121+ you just create a ``Blob `` inside your bucket
122+ and store your data inside the blob ::
124123
125- >>> key = bucket.new_key ('greeting.txt')
126- >>> key .set_contents_from_string('Hello world!')
124+ >>> blob = bucket.new_blob ('greeting.txt')
125+ >>> blob .set_contents_from_string('Hello world!')
127126
128- :func: `new_key <gcloud.storage.bucket.Bucket.new_key > `
129- creates a :class: `Key <gcloud.storage.key.Key > ` object locally
127+ :func: `new_blob <gcloud.storage.bucket.Bucket.new_blob > `
128+ creates a :class: `Blob <gcloud.storage.blob.Blob > ` object locally
130129and
131- :func: `set_contents_from_string <gcloud.storage.key.Key .set_contents_from_string> `
132- allows you to put a string into the key .
130+ :func: `set_contents_from_string <gcloud.storage.blob.Blob .set_contents_from_string> `
131+ allows you to put a string into the blob .
133132
134133Now we can test if it worked::
135134
136- >>> key = bucket.get_key ('greeting.txt')
137- >>> print key .get_contents_as_string()
135+ >>> blob = bucket.get_blob ('greeting.txt')
136+ >>> print blob .get_contents_as_string()
138137 Hello world!
139138
140139What if you want to save the contents to a file?
141140
142- >>> key .get_contents_to_filename(' greetings.txt' )
141+ >>> blob .get_contents_to_filename(' greetings.txt' )
143142
144143Then you can look at the file in a terminal::
145144
@@ -149,32 +148,32 @@ Then you can look at the file in a terminal::
149148And what about when you're not dealing with text?
150149That's pretty simple too::
151150
152- >>> key = bucket.new_key ('kitten.jpg')
153- >>> key .set_contents_from_filename('kitten.jpg')
151+ >>> blob = bucket.new_blob ('kitten.jpg')
152+ >>> blob .set_contents_from_filename('kitten.jpg')
154153
155154And to test whether it worked?
156155
157- >>> key = bucket.get_key (' kitten.jpg' )
158- >>> key .get_contents_to_filename(' kitten2.jpg' )
156+ >>> blob = bucket.get_blob (' kitten.jpg' )
157+ >>> blob .get_contents_to_filename(' kitten2.jpg' )
159158
160159and check if they are the same in a terminal::
161160
162161 $ diff kitten.jpg kitten2.jpg
163162
164163Notice that we're using
165- :func: `get_key <gcloud.storage.bucket.Bucket.get_key > `
166- to retrieve a key we know exists remotely.
167- If the key doesn't exist, it will return ``None ``.
164+ :func: `get_blob <gcloud.storage.bucket.Bucket.get_blob > `
165+ to retrieve a blob we know exists remotely.
166+ If the blob doesn't exist, it will return ``None ``.
168167
169- .. note :: ``get_key `` is **not** retrieving the entire object's data.
168+ .. note :: ``get_blob `` is **not** retrieving the entire object's data.
170169
171- If you want to "get-or-create" the key
170+ If you want to "get-or-create" the blob
172171(that is, overwrite it if it already exists),
173- you can use :func: `new_key <gcloud.storage.bucket.Bucket.new_key > `.
174- However, keep in mind, the key is not created
172+ you can use :func: `new_blob <gcloud.storage.bucket.Bucket.new_blob > `.
173+ However, keep in mind, the blob is not created
175174until you store some data inside of it.
176175
177- If you want to check whether a key exists,
176+ If you want to check whether a blob exists,
178177you can use the ``in `` operator in Python::
179178
180179 >>> print 'kitten.jpg' in bucket
@@ -191,17 +190,17 @@ to retrieve the bucket object::
191190
192191 >>> bucket = connection.get_bucket('my-bucket')
193192
194- If you want to get all the keys in the bucket,
193+ If you want to get all the blobs in the bucket,
195194you can use
196- :func: `get_all_keys <gcloud.storage.bucket.Bucket.get_all_keys > `::
195+ :func: `get_all_blobs <gcloud.storage.bucket.Bucket.get_all_blobs > `::
197196
198- >>> keys = bucket.get_all_keys ()
197+ >>> blobs = bucket.get_all_blobs ()
199198
200- However, if you're looking to iterate through the keys ,
199+ However, if you're looking to iterate through the blobs ,
201200you can use the bucket itself as an iterator::
202201
203- >>> for key in bucket:
204- ... print key
202+ >>> for blob in bucket:
203+ ... print blob
205204
206205Deleting a bucket
207206-----------------
@@ -234,7 +233,7 @@ Managing access control
234233-----------------------
235234
236235Cloud storage provides fine-grained access control
237- for both buckets and keys .
236+ for both buckets and blobs .
238237`gcloud ` tries to simplify access control
239238by working with entities and "grants".
240239On any ACL,
0 commit comments