Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

gcs: add --gcs-endpoint flag and config parameter

Nick Craig-Wood1ad22b8881ce
diff --git a/backend/googlecloudstorage/googlecloudstorage.go b/backend/googlecloudstorage/googlecloudstorage.go
index 0e6a2b4ed..5ce96e672 100644
--- a/backend/googlecloudstorage/googlecloudstorage.go
+++ b/backend/googlecloudstorage/googlecloudstorage.go
@@ -319,6 +319,10 @@ can't check the size and hash but the file contents will be decompressed.
`,
Advanced: true,
Default: false,
+ }, {
+ Name: "endpoint",
+ Help: "Endpoint for the service.\n\nLeave blank normally.",
+ Advanced: true,
}, {
Name: config.ConfigEncoding,
Help: config.ConfigEncodingHelp,
@@ -343,6 +347,7 @@ type Options struct {
StorageClass string `config:"storage_class"`
NoCheckBucket bool `config:"no_check_bucket"`
Decompress bool `config:"decompress"`
+ Endpoint string `config:"endpoint"`
Enc encoder.MultiEncoder `config:"encoding"`
}
@@ -523,7 +528,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
// Create a new authorized Drive client.
f.client = oAuthClient
- f.svc, err = storage.NewService(context.Background(), option.WithHTTPClient(f.client))
+ gcsOpts := []option.ClientOption{option.WithHTTPClient(f.client)}
+ if opt.Endpoint != "" {
+ gcsOpts = append(gcsOpts, option.WithEndpoint(opt.Endpoint))
+ }
+ f.svc, err = storage.NewService(context.Background(), gcsOpts...)
if err != nil {
return nil, fmt.Errorf("couldn't create Google Cloud Storage client: %w", err)
}