diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 37d73ff..e3c5984 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -4,7 +4,9 @@ Changelog
6.3.0 (unreleased)
------------------
-- Nothing changed yet.
+**New features**
+
+- Include the Google Cloud backend automatically when ``kinto.attachment.gcloud.*`` settings are used.
6.2.0 (2021-12-02)
diff --git a/README.rst b/README.rst
index ce11e9a..8c797c0 100644
--- a/README.rst
+++ b/README.rst
@@ -64,6 +64,18 @@ Store on Amazon S3:
See `Pyramid Storage `_.
+Google Cloud Storage
+--------------------
+
+.. code-block:: ini
+
+ kinto.attachment.gcloud.credentials =
+ kinto.attachment.gcloud.bucket_name =
+ kinto.attachment.gcloud.acl = publicRead
+
+See `Google Cloud ACL permissions `_
+
+
The ``folder`` option
---------------------
diff --git a/kinto_attachment/__init__.py b/kinto_attachment/__init__.py
index c2621d7..c7f5f6b 100644
--- a/kinto_attachment/__init__.py
+++ b/kinto_attachment/__init__.py
@@ -69,6 +69,8 @@ def includeme(config):
# Enable attachment backend.
if 'storage.base_path' in storage_settings:
config.include('pyramid_storage.local')
+ elif 'storage.gcloud.credentials' in storage_settings:
+ config.include('pyramid_storage.gcloud')
else:
config.include('pyramid_storage.s3')
diff --git a/kinto_attachment/tests/test_plugin_setup.py b/kinto_attachment/tests/test_plugin_setup.py
index 3dfba5c..cd3eb7c 100644
--- a/kinto_attachment/tests/test_plugin_setup.py
+++ b/kinto_attachment/tests/test_plugin_setup.py
@@ -3,6 +3,9 @@
from pyramid import testing
from pyramid.exceptions import ConfigurationError
+from pyramid_storage.interfaces import IFileStorage
+from pyramid_storage.s3 import S3FileStorage
+from pyramid_storage.gcloud import GoogleCloudStorage
from kinto import main as kinto_main
from kinto_attachment import __version__, includeme
@@ -58,3 +61,17 @@ def test_base_url_is_added_a_trailing_slash(self):
"attachment.base_url": "http://cdn.com",
})
assert config.registry.api_capabilities["attachments"]["base_url"] == "http://cdn.com/"
+
+ def test_gcloud_is_used_if_credentials_setting_is_used(self):
+ config = self.includeme(settings={
+ "attachment.gcloud.credentials": "/path/to/credentials.json",
+ "attachment.gcloud.bucket_name": "foo",
+ })
+ assert isinstance(config.registry.queryUtility(IFileStorage), GoogleCloudStorage)
+
+ def test_s3_is_used_if_base_path_setting_is_not_used(self):
+ config = self.includeme(settings={
+ "attachment.aws.access_key": "abc",
+ "attachment.aws.bucket_name": "foo",
+ })
+ assert isinstance(config.registry.queryUtility(IFileStorage), S3FileStorage)
diff --git a/setup.py b/setup.py
index bceeaf6..e645081 100644
--- a/setup.py
+++ b/setup.py
@@ -14,6 +14,7 @@
requirements = [
'boto',
+ 'google-cloud-storage',
'kinto<15', # content-type header in delete responses
'pyramid_storage>=0.1.0',
]