"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Swift storageUrl overloading fixes #167
Xavier Lucasc2e8f06bfaf2
diff --git a/docs/content/swift.md b/docs/content/swift.mdindex ecbce831c..3b7d21ed6 100644--- a/docs/content/swift.md+++ b/docs/content/swift.md@@ -56,6 +56,8 @@ Choose a number from below, or type in your own valueauth> 1Tenant name - optionaltenant>+Storage URL - optional+storage_url>Remote config--------------------[remote]@@ -63,6 +65,7 @@ user = user_namekey = password_or_api_keyauth = https://auth.api.rackspacecloud.com/v1.0tenant =+storage_url =--------------------y) Yes this is OKe) Edit this remotediff --git a/swift/auth.go b/swift/auth.gonew file mode 100644index 000000000..1eecdbce6--- /dev/null+++ b/swift/auth.go@@ -0,0 +1,30 @@+package swift++import "github.com/ncw/swift"++// auth is an authenticator for swift+type auth struct {+ swift.Authenticator+ storageURL string+}++// newAuth creates a swift authenticator wrapper to override the+// StorageUrl method.+func newAuth(Authenticator swift.Authenticator, storageURL string) *auth {+ return &auth{+ Authenticator: Authenticator,+ storageURL: storageURL,+ }+}++// The public storage URL - set Internal to true to read+// internal/service net URL+func (a *auth) StorageUrl(Internal bool) string {+ if a.storageURL != "" {+ return a.storageURL+ }+ return a.Authenticator.StorageUrl(Internal)+}++// Check the interfaces are satisfied+var _ swift.Authenticator = (*auth)(nil)diff --git a/swift/swift.go b/swift/swift.goindex 3c6dbbaf3..89d803a83 100644--- a/swift/swift.go+++ b/swift/swift.go@@ -66,6 +66,9 @@ func init() {}, {Name: "region",Help: "Region name - optional",+ }, {+ Name: "storage_url",+ Help: "Storage URL - optional",},},})@@ -176,6 +179,12 @@ func NewFsWithConnection(name, root string, c *swift.Connection) (fs.Fs, error)segmentsContainer: container + "_segments",root: directory,}+ // StorageURL overloading+ storageURL := fs.ConfigFile.MustValue(name, "storage_url")+ if storageURL != "" {+ f.c.StorageUrl = storageURL+ f.c.Auth = newAuth(f.c.Auth, storageURL)+ }if f.root != "" {f.root += "/"// Check to see if the object exists - ignoring directory markers