Skip to content

Commit 3234813

Browse files
committed
Removing uses of boto aliases.
1 parent 146a16c commit 3234813

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ to Cloud Storage using this Client Library.
9696
bucket = gcloud.storage.get_bucket('bucket-id-here', 'project-id')
9797
# Then do other things...
9898
blob = bucket.get_blob('/remote/path/to/file.txt')
99-
print blob.get_contents_as_string()
100-
blob.set_contents_from_string('New contents!')
99+
print blob.download_as_string()
100+
blob.upload_from_string('New contents!')
101101
bucket.upload_file('/remote/path/storage.txt', '/local/path.txt')
102102
103103
Contributing

docs/_components/storage-getting-started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,23 @@ you just create a ``Blob`` inside your bucket
122122
and store your data inside the blob::
123123

124124
>>> blob = bucket.new_blob('greeting.txt')
125-
>>> blob.set_contents_from_string('Hello world!')
125+
>>> blob.upload_from_string('Hello world!')
126126

127127
:func:`new_blob <gcloud.storage.bucket.Bucket.new_blob>`
128128
creates a :class:`Blob <gcloud.storage.blob.Blob>` object locally
129129
and
130-
:func:`set_contents_from_string <gcloud.storage.blob.Blob.set_contents_from_string>`
130+
:func:`upload_from_string <gcloud.storage.blob.Blob.upload_from_string>`
131131
allows you to put a string into the blob.
132132

133133
Now we can test if it worked::
134134

135135
>>> blob = bucket.get_blob('greeting.txt')
136-
>>> print blob.get_contents_as_string()
136+
>>> print blob.download_as_string()
137137
Hello world!
138138

139139
What if you want to save the contents to a file?
140140

141-
>>> blob.get_contents_to_filename('greetings.txt')
141+
>>> blob.download_to_file('greetings.txt')
142142

143143
Then you can look at the file in a terminal::
144144

@@ -149,12 +149,12 @@ And what about when you're not dealing with text?
149149
That's pretty simple too::
150150

151151
>>> blob = bucket.new_blob('kitten.jpg')
152-
>>> blob.set_contents_from_filename('kitten.jpg')
152+
>>> blob.upload_from_filename('kitten.jpg')
153153

154154
And to test whether it worked?
155155

156156
>>> blob = bucket.get_blob('kitten.jpg')
157-
>>> blob.get_contents_to_filename('kitten2.jpg')
157+
>>> blob.download_to_file('kitten2.jpg')
158158

159159
and check if they are the same in a terminal::
160160

docs/_components/storage-quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ you can create buckets and blobs::
6363
>>> blob = bucket.new_blob('my-test-file.txt')
6464
>>> print blob
6565
<Blob: my-new-bucket, my-test-file.txt>
66-
>>> blob = blob.set_contents_from_string('this is test content!')
67-
>>> print blob.get_contents_as_string()
66+
>>> blob = blob.upload_from_string('this is test content!')
67+
>>> print blob.download_as_string()
6868
'this is test content!'
6969
>>> print bucket.get_all_blobs()
7070
[<Blob: my-new-bucket, my-test-file.txt>]

gcloud/storage/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
>>> bucket = gcloud.storage.get_bucket('bucket-id-here', 'project-id')
2121
>>> # Then do other things...
2222
>>> blob = bucket.get_blob('/remote/path/to/file.txt')
23-
>>> print blob.get_contents_as_string()
24-
>>> blob.set_contents_from_string('New contents!')
23+
>>> print blob.download_as_string()
24+
>>> blob.upload_from_string('New contents!')
2525
>>> bucket.upload_file('/remote/path/storage.txt', '/local/path.txt')
2626
2727
The main concepts with this API are:

gcloud/storage/demo/demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
blob = bucket.new_blob("my-new-file.txt")
4040

4141
# Now let's put some data in there.
42-
blob.set_contents_from_string("this is some data!")
42+
blob.upload_from_string("this is some data!")
4343

4444
# ... and we can read that data back again.
45-
print(blob.get_contents_as_string())
45+
print(blob.download_as_string())
4646

4747
# Now let's delete that blob.
4848
print(blob.delete())

regression/storage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def test_direct_write_and_read_into_file(self):
177177
same_blob = self.bucket.new_blob('MyBuffer')
178178
temp_filename = tempfile.mktemp()
179179
with open(temp_filename, 'w') as file_obj:
180-
same_blob.get_contents_to_file(file_obj)
180+
same_blob.download_to_file(file_obj)
181181

182182
with open(temp_filename, 'rb') as file_obj:
183183
stored_contents = file_obj.read()
@@ -192,8 +192,8 @@ def test_copy_existing_file(self):
192192
new_blob = self.bucket.copy_blob(blob, self.bucket, 'CloudLogoCopy')
193193
self.case_blobs_to_delete.append(new_blob)
194194

195-
base_contents = blob.get_contents_as_string()
196-
copied_contents = new_blob.get_contents_as_string()
195+
base_contents = blob.download_as_string()
196+
copied_contents = new_blob.download_as_string()
197197
self.assertEqual(base_contents, copied_contents)
198198

199199

0 commit comments

Comments
 (0)