diff --git a/ShareX.UploadersLib/FileUploaders/Dropbox.cs b/ShareX.UploadersLib/FileUploaders/Dropbox.cs index e8b590081..803913685 100644 --- a/ShareX.UploadersLib/FileUploaders/Dropbox.cs +++ b/ShareX.UploadersLib/FileUploaders/Dropbox.cs @@ -49,11 +49,12 @@ public override bool CheckConfig(UploadersConfig config) public override GenericUploader CreateUploader(UploadersConfig config, TaskReferenceHelper taskInfo) { - return new Dropbox(config.DropboxOAuth2Info, config.DropboxAccount) + return new Dropbox(config.DropboxOAuth2Info) { UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(config.DropboxUploadPath)), AutoCreateShareableLink = config.DropboxAutoCreateShareableLink, - ShareURLType = config.DropboxURLType + ShareURLType = config.DropboxURLType, + AccountInfo = config.DropboxAccountInfo }; } @@ -71,6 +72,7 @@ public sealed class Dropbox : FileUploader, IOAuth2Basic { public OAuth2Info AuthInfo { get; set; } public DropboxAccount Account { get; set; } + public DropboxAccountInfo AccountInfo { get; set; } // API v1 public string UploadPath { get; set; } public bool AutoCreateShareableLink { get; set; } public DropboxURLType ShareURLType { get; set; } @@ -105,11 +107,6 @@ public Dropbox(OAuth2Info oauth) AuthInfo = oauth; } - public Dropbox(OAuth2Info oauth, DropboxAccount account) : this(oauth) - { - Account = account; - } - public string GetAuthorizationURL() { Dictionary args = new Dictionary(); @@ -452,7 +449,7 @@ private void CheckEarlyURLCopy(string path, string fileName) public string GetPublicURL(string path) { // TODO: uid - return GetPublicURL(Account.account_id, path); + return GetPublicURL(AccountInfo.Uid.ToString(), path); } public static string GetPublicURL(string userID, string path) @@ -594,4 +591,25 @@ public class DropboxLinkMetadataTeamInfo public string id { get; set; } public string name { get; set; } } + + #region API v1 + + public class DropboxAccountInfo + { + public string Referral_link { get; set; } + public string Display_name { get; set; } + public long Uid { get; set; } + public string Country { get; set; } + public DropboxQuotaInfo Quota_info { get; set; } + public string Email { get; set; } + } + + public class DropboxQuotaInfo + { + public long Normal { get; set; } + public long Shared { get; set; } + public long Quota { get; set; } + } + + #endregion API v1 } \ No newline at end of file diff --git a/ShareX.UploadersLib/UploadersConfig.cs b/ShareX.UploadersLib/UploadersConfig.cs index 254d14db4..956c727a3 100644 --- a/ShareX.UploadersLib/UploadersConfig.cs +++ b/ShareX.UploadersLib/UploadersConfig.cs @@ -134,6 +134,7 @@ public class UploadersConfig : SettingsBase public string DropboxUploadPath = "Public/ShareX/%y/%mo"; public bool DropboxAutoCreateShareableLink = false; public DropboxURLType DropboxURLType = DropboxURLType.Default; + public DropboxAccountInfo DropboxAccountInfo = null; // API v1 // FTP Server