Skip to content

Commit

Permalink
docs: add links to samples and how to guides (#641)
Browse files Browse the repository at this point in the history
* docs: add section for more examples

* docs: revise example usage
  • Loading branch information
cojenco committed Nov 2, 2021
1 parent 0b7838a commit 49f78b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 7 additions & 9 deletions README.rst
Expand Up @@ -88,21 +88,19 @@ Windows
Example Usage
~~~~~~~~~~~~~

You need to create a Google Cloud Storage bucket to use this client library.
Follow along with the `official Google Cloud Storage documentation`_ to learn
how to create a bucket.

.. _official Google Cloud Storage documentation: https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets

.. code:: python
from google.cloud import storage
client = storage.Client()
new_bucket = client.create_bucket('new-bucket-id')
new_blob = new_bucket.blob('remote/path/storage.txt')
new_blob.upload_from_filename(filename='/local/path.txt')
# Retrieve an existing bucket
# https://console.cloud.google.com/storage/browser/[bucket-id]/
bucket = client.get_bucket('bucket-id-here')
bucket = client.get_bucket('bucket-id')
# Then do other things...
blob = bucket.get_blob('remote/path/to/file.txt')
print(blob.download_as_bytes())
blob.upload_from_string('New contents!')
blob2 = bucket.blob('remote/path/storage.txt')
blob2.upload_from_filename(filename='/local/path.txt')
8 changes: 8 additions & 0 deletions docs/index.rst
Expand Up @@ -24,6 +24,14 @@ API Reference
retry_timeout
generation_metageneration

More Examples
-------------
.. toctree::
:maxdepth: 2

Official Google Cloud Storage How-to Guides <https://cloud.google.com/storage/docs/how-to>
Official Google Cloud Storage Samples <https://cloud.google.com/storage/docs/samples>

Changelog
---------
.. toctree::
Expand Down

0 comments on commit 49f78b0

Please sign in to comment.