Browse Source

Add a GCS example.

Jelmer Vernooij 4 years ago
parent
commit
29c1c2290d
1 changed files with 14 additions and 0 deletions
  1. 14 0
      examples/gcs.py

+ 14 - 0
examples/gcs.py

@@ -0,0 +1,14 @@
+#!/usr/bin/python3
+
+from dulwich.repo import Repo
+from dulwich.cloud.gcs import GcsObjectStore
+
+import tempfile
+
+from google.cloud import storage
+
+client = storage.Client()
+bucket = client.get_bucket('mybucket')
+
+gcs_object_store = GcsObjectStore(bucket, 'path')
+r = Repo.init_bare(tempfile.mkdtemp(), object_store=gcs_object_store)