Store Dropbox API v1 account info so public url can be generated

This commit is contained in:
Jaex 2016-06-30 03:55:17 +03:00
parent 22aa10e72e
commit c6b21bcdcc
2 changed files with 27 additions and 8 deletions

View file

@ -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<string, string> args = new Dictionary<string, string>();
@ -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
}

View file

@ -134,6 +134,7 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public string DropboxUploadPath = "Public/ShareX/%y/%mo";
public bool DropboxAutoCreateShareableLink = false;
public DropboxURLType DropboxURLType = DropboxURLType.Default;
public DropboxAccountInfo DropboxAccountInfo = null; // API v1
// FTP Server