Google Cloud Storage¶
GoogleStorageDriver
is a wrapper around google-cloud-storage.
Connecting¶
The driver will check for GOOGLE_APPLICATION_CREDENTIALS
environment variable
before connecting. If not found, the driver will use service worker credentials
json file path passed to key
argument.
from cloudstorage.drivers.google import GoogleStorageDriver
credentials_json_file = '/path/cloud-storage-service-account.json'
storage = GoogleStorageDriver(key=credentials_json_file)
# <Driver: GOOGLESTORAGE>
Access Control List (ACL)¶
By default, all containers and blobs default to project-private
. To change
the access control when creating a container or blob, include the acl
argument:
container = storage.create_container('container-public', acl='public-read')
container.cdn_url
# https://storage.googleapis.com/container-public
container = storage.get_container('container-public')
picture_blob = container.upload_blob('/path/picture.png', acl='public-read')
picture_blob.cdn_url
# https://storage.googleapis.com/container-public/picture.png
Support ACL values for Google Cloud Storage:
- private
- public-read
- public-read-write
- authenticated-read
- bucket-owner-read
- bucket-owner-full-control
- project-private
Warning
Updating ACL on an existing container or blob is not currently supported.
Content Delivery Network (CDN)¶
Calling container.enable_cdn()
will make the container public
(shared publicly). More information available at Making Data Public.