@@ -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 objects ,
88and how to handle access control,
99among other things.
1010
@@ -113,33 +113,28 @@ by recognizing forward-slashes (``/``)
113113so if you want to group data into "directories",
114114you can do that.
115115
116- The 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 ``.
120-
121116If you want to set some data,
122- you just create a ``Key `` inside your bucket
123- and store your data inside the key ::
117+ you just create a ``Object `` inside your bucket
118+ and store your data inside it ::
124119
125- >>> key = bucket.new_key ('greeting.txt')
126- >>> key .set_contents_from_string('Hello world!')
120+ >>> object_ = bucket.new_object ('greeting.txt')
121+ >>> object_ .set_contents_from_string('Hello world!')
127122
128- :func: `new_key <gcloud.storage.bucket.Bucket.new_key > `
129- creates a :class: `Key <gcloud.storage.key.Key > ` object locally
123+ :func: `new_object <gcloud.storage.bucket.Bucket.new_object > `
124+ creates a :class: `Object <gcloud.storage.object_.Object > ` object locally
130125and
131- :func: `set_contents_from_string <gcloud.storage.key.Key .set_contents_from_string> `
132- allows you to put a string into the key .
126+ :func: `set_contents_from_string <gcloud.storage.object_.Object .set_contents_from_string> `
127+ allows you to put a string into the object .
133128
134129Now we can test if it worked::
135130
136- >>> key = bucket.get_key ('greeting.txt')
137- >>> print key .get_contents_as_string()
131+ >>> object_ = bucket.get_object ('greeting.txt')
132+ >>> print object_ .get_contents_as_string()
138133 Hello world!
139134
140135What if you want to save the contents to a file?
141136
142- >>> key .get_contents_to_filename(' greetings.txt' )
137+ >>> object_ .get_contents_to_filename(' greetings.txt' )
143138
144139Then you can look at the file in a terminal::
145140
@@ -149,32 +144,32 @@ Then you can look at the file in a terminal::
149144And what about when you're not dealing with text?
150145That's pretty simple too::
151146
152- >>> key = bucket.new_key ('kitten.jpg')
153- >>> key .set_contents_from_filename('kitten.jpg')
147+ >>> object_ = bucket.new_object ('kitten.jpg')
148+ >>> object_ .set_contents_from_filename('kitten.jpg')
154149
155150And to test whether it worked?
156151
157- >>> key = bucket.get_key (' kitten.jpg' )
158- >>> key .get_contents_to_filename(' kitten2.jpg' )
152+ >>> object_ = bucket.get_object (' kitten.jpg' )
153+ >>> object_ .get_contents_to_filename(' kitten2.jpg' )
159154
160155and check if they are the same in a terminal::
161156
162157 $ diff kitten.jpg kitten2.jpg
163158
164159Notice 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 ``.
160+ :func: `get_object <gcloud.storage.bucket.Bucket.get_object > `
161+ to retrieve an object we know exists remotely.
162+ If the object doesn't exist, it will return ``None ``.
168163
169- .. note :: ``get_key `` is **not** retrieving the entire object's data.
164+ .. note :: ``get_object `` is **not** retrieving the entire object's data.
170165
171- If you want to "get-or-create" the key
166+ If you want to "get-or-create" the object
172167(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
168+ you can use :func: `new_object <gcloud.storage.bucket.Bucket.new_object > `.
169+ However, keep in mind, the object is not created
175170until you store some data inside of it.
176171
177- If you want to check whether a key exists,
172+ If you want to check whether an object exists,
178173you can use the ``in `` operator in Python::
179174
180175 >>> print 'kitten.jpg' in bucket
@@ -191,17 +186,17 @@ to retrieve the bucket object::
191186
192187 >>> bucket = connection.get_bucket('my-bucket')
193188
194- If you want to get all the keys in the bucket,
189+ If you want to get all the objects in the bucket,
195190you can use
196- :func: `get_all_keys <gcloud.storage.bucket.Bucket.get_all_keys > `::
191+ :func: `get_all_objects <gcloud.storage.bucket.Bucket.get_all_objects > `::
197192
198- >>> keys = bucket.get_all_keys ()
193+ >>> objects = bucket.get_all_objects ()
199194
200- However, if you're looking to iterate through the keys ,
195+ However, if you're looking to iterate through the objects ,
201196you can use the bucket itself as an iterator::
202197
203- >>> for key in bucket:
204- ... print key
198+ >>> for object_ in bucket:
199+ ... print object_
205200
206201Deleting a bucket
207202-----------------
@@ -234,7 +229,7 @@ Managing access control
234229-----------------------
235230
236231Cloud storage provides fine-grained access control
237- for both buckets and keys .
232+ for both buckets and objects .
238233`gcloud ` tries to simplify access control
239234by working with entities and "grants".
240235On any ACL,
0 commit comments