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

dropbox: set visibility in link sharing when --expire is set

Nick Craig-Woodfcba51557f99
diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go
index 2ac05b565..ea98d36b6 100755
--- a/backend/dropbox/dropbox.go
+++ b/backend/dropbox/dropbox.go
@@ -1084,13 +1084,30 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration,
fs.Debugf(f, "attempting to share '%s' (absolute path: %s)", remote, absPath)
createArg := sharing.CreateSharedLinkWithSettingsArg{
Path: absPath,
- // FIXME this gives settings_error/not_authorized/.. errors
- // and the expires setting isn't in the documentation so remove
- // for now.
- // Settings: &sharing.SharedLinkSettings{
- // Expires: time.Now().Add(time.Duration(expire)).UTC().Round(time.Second),
- // },
+ Settings: &sharing.SharedLinkSettings{
+ RequestedVisibility: &sharing.RequestedVisibility{
+ Tagged: dropbox.Tagged{Tag: sharing.RequestedVisibilityPublic},
+ },
+ Audience: &sharing.LinkAudience{
+ Tagged: dropbox.Tagged{Tag: sharing.LinkAudiencePublic},
+ },
+ Access: &sharing.RequestedLinkAccessLevel{
+ Tagged: dropbox.Tagged{Tag: sharing.RequestedLinkAccessLevelViewer},
+ },
+ },
+ }
+ if expire < fs.DurationOff {
+ expiryTime := time.Now().Add(time.Duration(expire)).UTC().Round(time.Second)
+ createArg.Settings.Expires = expiryTime
}
+ // FIXME note we can't set Settings for non enterprise dropbox
+ // because of https://github.com/dropbox/dropbox-sdk-go-unofficial/issues/75
+ // however this only goes wrong when we set Expires, so as a
+ // work-around remove Settings unless expire is set.
+ if expire == fs.DurationOff {
+ createArg.Settings = nil
+ }
+
var linkRes sharing.IsSharedLinkMetadata
err = f.pacer.Call(func() (bool, error) {
linkRes, err = f.sharing.CreateSharedLinkWithSettings(&createArg)
diff --git a/docs/content/dropbox.md b/docs/content/dropbox.md
index 6acb34b1d..ae91c1cb2 100644
--- a/docs/content/dropbox.md
+++ b/docs/content/dropbox.md
@@ -285,6 +285,12 @@ dropbox:dir` will return the error `Failed to purge: There are too
many files involved in this operation`. As a work-around do an
`rclone delete dropbox:dir` followed by an `rclone rmdir dropbox:dir`.
+When using `rclone link` you'll need to set `--expire` if using a
+non-personal account otherwise the visibility may not be correct.
+(Note that `--expire` isn't supported on personal accounts). See the
+[forum discussion](https://forum.rclone.org/t/rclone-link-dropbox-permissions/23211) and the
+[dropbox SDK issue](https://github.com/dropbox/dropbox-sdk-go-unofficial/issues/75).
+
### Get your own Dropbox App ID ###
When you use rclone with Dropbox in its default configuration you are using rclone's App ID. This is shared between all the rclone users.