"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: enhance link creation with expiry, scope, type and password
Nick Craig-Woodd58fdb10db0e
diff --git a/backend/onedrive/api/types.go b/backend/onedrive/api/types.goindex e144e5868..394403b0e 100644--- a/backend/onedrive/api/types.go+++ b/backend/onedrive/api/types.go@@ -253,8 +253,10 @@ type MoveItemRequest struct {//CreateShareLinkRequest is the request to create a sharing link//Always Type:view and Scope:anonymous for public sharingtype CreateShareLinkRequest struct {- Type string `json:"type"` //Link type in View, Edit or Embed- Scope string `json:"scope,omitempty"` //Optional. Scope in anonymous, organization+ Type string `json:"type"` // Link type in View, Edit or Embed+ Scope string `json:"scope,omitempty"` // Scope in anonymous, organization+ Password string `json:"password,omitempty"` // The password of the sharing link that is set by the creator. Optional and OneDrive Personal only.+ Expiry *time.Time `json:"expirationDateTime,omitempty"` // A String with format of yyyy-MM-ddTHH:mm:ssZ of DateTime indicates the expiration time of the permission.}//CreateShareLinkResponse is the response from CreateShareLinkRequestdiff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.goindex cade6eef1..a98bdb3ce 100755--- a/backend/onedrive/onedrive.go+++ b/backend/onedrive/onedrive.go@@ -295,6 +295,41 @@ modification time and removes all but the last version.**NB** Onedrive personal can't currently delete versions so don't usethis flag there.+`,+ Advanced: true,+ }, {+ Name: "link_scope",+ Default: "anonymous",+ Help: `Set the scope of the links created by the link command.`,+ Advanced: true,+ Examples: []fs.OptionExample{{+ Value: "anonymous",+ Help: "Anyone with the link has access, without needing to sign in. This may include people outside of your organization. Anonymous link support may be disabled by an administrator.",+ }, {+ Value: "organization",+ Help: "Anyone signed into your organization (tenant) can use the link to get access. Only available in OneDrive for Business and SharePoint.",+ }},+ }, {+ Name: "link_type",+ Default: "view",+ Help: `Set the type of the links created by the link command.`,+ Advanced: true,+ Examples: []fs.OptionExample{{+ Value: "view",+ Help: "Creates a read-only link to the item.",+ }, {+ Value: "edit",+ Help: "Creates a read-write link to the item.",+ }, {+ Value: "embed",+ Help: "Creates an embeddable link to the item.",+ }},+ }, {+ Name: "link_password",+ Default: "",+ Help: `Set the password for links created by the link command.++At the time of writing this only works with OneDrive personal paid accounts.`,Advanced: true,}, {@@ -355,6 +390,9 @@ type Options struct {ExposeOneNoteFiles bool `config:"expose_onenote_files"`ServerSideAcrossConfigs bool `config:"server_side_across_configs"`NoVersions bool `config:"no_versions"`+ LinkScope string `config:"link_scope"`+ LinkType string `config:"link_type"`+ LinkPassword string `config:"link_password"`Enc encoder.MultiEncoder `config:"encoding"`}@@ -1303,8 +1341,14 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration,opts := newOptsCall(info.GetID(), "POST", "/createLink")share := api.CreateShareLinkRequest{- Type: "view",- Scope: "anonymous",+ Type: f.opt.LinkType,+ Scope: f.opt.LinkScope,+ Password: f.opt.LinkPassword,+ }++ if expire < fs.Duration(time.Hour*24*365*100) {+ expiry := time.Now().Add(time.Duration(expire))+ share.Expiry = &expiry}var resp *http.Response