"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
onedrive: Support addressing site by server-relative URL (#4761)
kiceef2bfb9718fe
diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.goindex 228b9d7d4..83705b7bb 100755--- a/backend/onedrive/onedrive.go+++ b/backend/onedrive/onedrive.go@@ -12,6 +12,7 @@ import ("log""net/http""path"+ "regexp""strconv""strings""sync"@@ -120,9 +121,18 @@ func init() {var opts rest.Optsvar finalDriveID stringvar siteID string+ var relativePath stringswitch config.Choose("Your choice",- []string{"onedrive", "sharepoint", "driveid", "siteid", "search"},- []string{"OneDrive Personal or Business", "Root Sharepoint site", "Type in driveID", "Type in SiteID", "Search a Sharepoint site"},+ []string{"onedrive", "sharepoint", "url", "search", "driveid", "siteid", "path"},+ []string{+ "OneDrive Personal or Business",+ "Root Sharepoint site",+ "Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)",+ "Search for a Sharepoint site",+ "Type in driveID (advanced)",+ "Type in SiteID (advanced)",+ "Sharepoint server-relative path (advanced, e.g. /teams/hr)",+ },false) {case "onedrive":@@ -143,6 +153,20 @@ func init() {case "siteid":fmt.Printf("Paste your Site ID here> ")siteID = config.ReadLine()+ case "url":+ fmt.Println("Example: \"https://contoso.sharepoint.com/sites/mysite\" or \"mysite\"")+ fmt.Printf("Paste your Site URL here> ")+ siteURL := config.ReadLine()+ re := regexp.MustCompile(`https://.*\.sharepoint.com/sites/(.*)`)+ match := re.FindStringSubmatch(siteURL)+ if len(match) == 2 {+ relativePath = "/sites/" + match[1]+ } else {+ relativePath = "/sites/" + siteURL+ }+ case "path":+ fmt.Printf("Enter server-relative URL here> ")+ relativePath = config.ReadLine()case "search":fmt.Printf("What to search for> ")searchTerm := config.ReadLine()@@ -169,6 +193,21 @@ func init() {}}+ // if we use server-relative URL for finding the drive+ if relativePath != "" {+ opts = rest.Opts{+ Method: "GET",+ RootURL: graphURL,+ Path: "/sites/root:" + relativePath,+ }+ site := siteResource{}+ _, err := srv.CallJSON(ctx, &opts, nil, &site)+ if err != nil {+ log.Fatalf("Failed to query available site by relative path: %v", err)+ }+ siteID = site.SiteID+ }+// if we have a siteID we need to ask for the drivesif siteID != "" {opts = rest.Opts{