Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tusd: Use GCS upload backend when the endpoint matches.

Alex Vandivere1aa8b1cb050
diff --git a/docs/production/upload-backends.md b/docs/production/upload-backends.md
index 00c1409600b..90990e57002 100644
--- a/docs/production/upload-backends.md
+++ b/docs/production/upload-backends.md
@@ -66,6 +66,25 @@ uploading files, this process does not upload them to Amazon S3; see
[migration instructions](#migrating-from-local-uploads-to-amazon-s3-backend)
below for those steps.
+### Google Cloud Platform
+
+In addition to configuring `settings.py` as suggested above:
+
+```python
+S3_AUTH_UPLOADS_BUCKET = "..."
+S3_AVATAR_BUCKET = "..."
+S3_ENDPOINT_URL = "https://storage.googleapis.com"
+S3_SKIP_CHECKSUM = True
+```
+
+...and adding `s3_key` and `s3_secret_key` in `/etc/zulip/zulip-secrets.conf`,
+you will need to also add a `/etc/zulip/gcp_key.json` which contains a [service
+account key][gcp-key] with "Storage Object Admin" permissions on the uploads
+bucket. This is used by the `tusd` chunked upload service when receiving file
+uploads from clients.
+
+[gcp-key]: https://cloud.google.com/iam/docs/keys-create-delete
+
## S3 local caching
For performance reasons, Zulip stores a cache of recently served user
diff --git a/zerver/management/commands/runtusd.py b/zerver/management/commands/runtusd.py
index 2f76d2dce33..fe9dae912a4 100644
--- a/zerver/management/commands/runtusd.py
+++ b/zerver/management/commands/runtusd.py
@@ -63,6 +63,12 @@ class Command(BaseCommand):
if settings.LOCAL_UPLOADS_DIR is not None:
assert settings.LOCAL_FILES_DIR is not None
tusd_args.append(f"-upload-dir={settings.LOCAL_FILES_DIR}")
+ elif settings.S3_ENDPOINT_URL in (
+ "https://storage.googleapis.com",
+ "https://storage.googleapis.com/",
+ ):
+ tusd_args.append(f"-gcs-bucket={settings.S3_AUTH_UPLOADS_BUCKET}")
+ env_vars["GCS_SERVICE_ACCOUNT_FILE"] = "/etc/zulip/gcp_key.json"
else:
tusd_args.append(f"-s3-bucket={settings.S3_AUTH_UPLOADS_BUCKET}")
if settings.S3_ENDPOINT_URL is not None: