public override GenericUploader CreateUploader(UploadersConfig config, TaskReferenceHelper taskInfo) { OAuth2Info oauth = new OAuth2Info(APIKeys.SlimgClientID, APIKeys.SlimgClientSecret); return new Slimg(oauth) { UploadMethod = AccountType.Anonymous }; }
public DropboxFilesForm(OAuth2Info oauth, string path, DropboxAccountInfo accountInfo) { InitializeComponent(); Icon = ShareXResources.Icon; dropbox = new Dropbox(oauth); dropboxAccountInfo = accountInfo; ilm = new ImageListManager(lvDropboxFiles); if (path != null) { Shown += (sender, e) => OpenDirectory(path); } }
public DropboxAccount GetCurrentAccount() { DropboxAccount account = null; if (OAuth2Info.CheckOAuth(AuthInfo)) { string response = SendRequestJSON(URLGetCurrentAccount, "null", GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { account = JsonConvert.DeserializeObject <DropboxAccount>(response); if (account != null) { Account = account; } } } return(account); }
public DropboxMetadata CreateFolder(string path) { DropboxMetadata metadata = null; if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo)) { string json = JsonConvert.SerializeObject(new { path = VerifyPath(path) }); string response = SendRequest(HttpMethod.POST, URLCreateFolder, json, RequestHelpers.ContentTypeJSON, null, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response); } } return(metadata); }
// https://www.dropbox.com/developers/core/docs#metadata public DropboxContentInfo GetMetadata(string path, bool list) { DropboxContentInfo contentInfo = null; if (OAuth2Info.CheckOAuth(AuthInfo)) { string url = URLHelpers.CombineURL(URLMetaData, URLHelpers.URLPathEncode(path)); Dictionary<string, string> args = new Dictionary<string, string>(); args.Add("list", list ? "true" : "false"); string response = SendRequest(HttpMethod.GET, url, args, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { contentInfo = JsonConvert.DeserializeObject<DropboxContentInfo>(response); } } return contentInfo; }
public DropboxMetadata Delete(string path) { DropboxMetadata metadata = null; if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo)) { string json = JsonConvert.SerializeObject(new { path = VerifyPath(path) }); string response = SendRequestJSON(URLDelete, json, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response); } } return(metadata); }
public DropboxAccountInfo GetCurrentAccountAPIv1() { DropboxAccountInfo account = null; if (OAuth2Info.CheckOAuth(AuthInfo)) { string response = SendRequest(HttpMethod.GET, URLAccountInfo, headers: GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { account = JsonConvert.DeserializeObject <DropboxAccountInfo>(response); if (account != null) { AccountInfo = account; } } } return(account); }
public DropboxMetadata Copy(string fromPath, string toPath) { DropboxMetadata metadata = null; if (!string.IsNullOrEmpty(fromPath) && !string.IsNullOrEmpty(toPath) && OAuth2Info.CheckOAuth(AuthInfo)) { string json = JsonConvert.SerializeObject(new { from_path = VerifyPath(fromPath), to_path = VerifyPath(toPath) }); string response = SendRequestJSON(URLCopy, json, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response); } } return(metadata); }
public DropboxListSharedLinksResult ListSharedLinks(string path, bool directOnly = false) { DropboxListSharedLinksResult result = null; if (path != null && OAuth2Info.CheckOAuth(AuthInfo)) { string json = JsonConvert.SerializeObject(new { path = VerifyPath(path), direct_only = directOnly }); string response = SendRequest(HttpMethod.POST, URLListSharedLinks, json, ContentTypeJSON, null, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { result = JsonConvert.DeserializeObject <DropboxListSharedLinksResult>(response); } } return(result); }
public DropboxMetadata Move(string fromPath, string toPath) { DropboxMetadata metadata = null; if (!string.IsNullOrEmpty(fromPath) && !string.IsNullOrEmpty(toPath) && OAuth2Info.CheckOAuth(AuthInfo)) { string json = JsonConvert.SerializeObject(new { from_path = VerifyPath(fromPath), to_path = VerifyPath(toPath) }); string response = SendRequest(HttpMethod.POST, URLMove, json, ContentTypeJSON, null, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response); } } return(metadata); }
public bool IsValid(UrlShortenerType destination) { switch (destination) { case UrlShortenerType.Google: return(GoogleURLShortenerAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(GoogleURLShortenerOAuth2Info)); case UrlShortenerType.BITLY: return(OAuth2Info.CheckOAuth(BitlyOAuth2Info)); case UrlShortenerType.YOURLS: return(!string.IsNullOrEmpty(YourlsAPIURL) && (!string.IsNullOrEmpty(YourlsSignature) || (!string.IsNullOrEmpty(YourlsUsername) && !string.IsNullOrEmpty(YourlsPassword)))); case UrlShortenerType.AdFly: return(!string.IsNullOrEmpty(AdFlyAPIKEY) && !string.IsNullOrEmpty(AdFlyAPIUID)); case UrlShortenerType.CustomURLShortener: return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomURLShortenerSelected)); } return(true); }
public bool IsActive(ImageDestination destination) { switch (destination) { case ImageDestination.ImageShack: return(ImageShackAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(ImageShackRegistrationCode)); case ImageDestination.TinyPic: return(TinyPicAccountType == AccountType.Anonymous || !string.IsNullOrEmpty(TinyPicRegistrationCode)); case ImageDestination.Imgur: return(ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info)); case ImageDestination.Flickr: return(!string.IsNullOrEmpty(FlickrAuthInfo.Token)); case ImageDestination.Photobucket: return(PhotobucketAccountInfo != null && OAuthInfo.CheckOAuth(PhotobucketOAuthInfo)); case ImageDestination.Picasa: return(OAuth2Info.CheckOAuth(PicasaOAuth2Info)); case ImageDestination.Twitpic: case ImageDestination.Twitsnaps: return(TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount)); case ImageDestination.yFrog: return(!string.IsNullOrEmpty(YFrogUsername) && !string.IsNullOrEmpty(YFrogPassword)); case ImageDestination.CustomImageUploader: return(CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected)); default: return(true); } }
private void ImgurAuthOpen() { try { OAuth2Info oauth = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret); string url = new Imgur(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.ImgurOAuth2Info = oauth; URLHelpers.OpenURL(url); DebugHelper.WriteLine("ImgurAuthOpen - Authorization URL is opened: " + url); } else { DebugHelper.WriteLine("ImgurAuthOpen - Authorization URL is empty."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DropboxMetadata GetMetadata(string path) { DropboxMetadata metadata = null; if (path != null && OAuth2Info.CheckOAuth(AuthInfo)) { string json = JsonConvert.SerializeObject(new { path = VerifyPath(path), include_media_info = false, include_deleted = false, include_has_explicit_shared_members = false }); string response = SendRequest(HttpMethod.POST, URLGetMetadata, json, ContentTypeJSON, null, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { metadata = JsonConvert.DeserializeObject <DropboxMetadata>(response); } } return(metadata); }
// https://www.dropbox.com/developers/core/docs#shares public string CreateShareableLink(string path, DropboxURLType urlType) { if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo)) { string url = URLHelpers.CombineURL(URLShares, URLHelpers.URLPathEncode(path)); Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false"); string response = SendRequest(HttpMethod.POST, url, args, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { DropboxShares shares = JsonConvert.DeserializeObject <DropboxShares>(response); if (urlType == DropboxURLType.Direct) { Match match = Regex.Match(shares.URL, @"https?://(?:www\.)?dropbox.com/s/(?<path>\w+/.+)"); if (match.Success) { string urlPath = match.Groups["path"].Value; if (!string.IsNullOrEmpty(urlPath)) { return(URLHelpers.CombineURL(URLShareDirect, urlPath)); } } } else { return(shares.URL); } } } return(null); }
private void OAuth_OpenAuthorizePageClick(object sender, RoutedEventArgs e) { try { OAuth2Info oauth = new OAuth2Info(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret); string url = new DropboxUploader(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { DropboxUploader.Config.DropboxOAuth2Info = oauth; URLHelper.OpenURL(url); DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is opened: " + url); } else { DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is empty."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public override bool CheckConfig(UploadersConfig config) { return(OAuth2Info.CheckOAuth(config.OneDriveV2OAuth2Info)); }
public GfycatUploader(OAuth2Info oauth) { AuthInfo = oauth; }
public Dropbox(OAuth2Info oauth) { AuthInfo = oauth; }
public void DropboxAuthOpen() { try { OAuth2Info oauth = new OAuth2Info(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret); string url = new Dropbox(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.DropboxOAuth2Info = oauth; URLHelpers.OpenURL(url); DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is opened: " + url); } else { DebugHelper.WriteLine("DropboxAuthOpen - Authorization URL is empty."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public GoogleURLShortener(AccountType uploadMethod, string anonymousKey, OAuth2Info oauth) { UploadMethod = uploadMethod; AnonymousKey = anonymousKey; AuthInfo = oauth; }
public Box(OAuth2Info oauth) { AuthInfo = oauth; FolderID = "0"; Share = true; }
public GoogleURLShortener(OAuth2Info oauth) { UploadMethod = AccountType.User; AuthInfo = oauth; }
public Imgur(OAuth2Info oauth) { AuthInfo = oauth; }
public GoogleDrive(OAuth2Info oauth) { AuthInfo = oauth; }
public static bool CheckOAuth(OAuth2Info oauth) { return oauth != null && !string.IsNullOrEmpty(oauth.Client_ID) && !string.IsNullOrEmpty(oauth.Client_Secret) && oauth.Token != null && !string.IsNullOrEmpty(oauth.Token.access_token); }
public Slimg(OAuth2Info oauth) { AuthInfo = oauth; }
public Picasa(OAuth2Info oauth) { AuthInfo = oauth; }
public override bool CheckConfig(UploadersConfig config) { return(OAuth2Info.CheckOAuth(config.GoogleCloudStorageOAuth2Info) && !string.IsNullOrEmpty(config.GoogleCloudStorageBucket)); }
public OneDrive(OAuth2Info authInfo) { AuthInfo = authInfo; }
public Minus(MinusOptions config, OAuth2Info auth) { Config = config; AuthInfo = auth; }
public void GistAuthOpen() { try { OAuth2Info oauth = new OAuth2Info(APIKeys.GitHubID, APIKeys.GitHubSecret); string url = new Gist(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.GistOAuth2Info = oauth; URLHelpers.OpenURL(url); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// https://www.dropbox.com/developers/core/docs#fileops-move public DropboxContentInfo Move(string from_path, string to_path) { DropboxContentInfo contentInfo = null; if (!string.IsNullOrEmpty(from_path) && !string.IsNullOrEmpty(to_path) && OAuth2Info.CheckOAuth(AuthInfo)) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("root", Root); args.Add("from_path", from_path); args.Add("to_path", to_path); string response = SendRequest(HttpMethod.POST, URLMove, args, GetAuthHeaders()); if (!string.IsNullOrEmpty(response)) { contentInfo = JsonConvert.DeserializeObject <DropboxContentInfo>(response); } } return(contentInfo); }
public BitlyURLShortener(OAuth2Info oauth) { AuthInfo = oauth; }
public Dropbox(OAuth2Info oauth, DropboxAccountInfo accountInfo) : this(oauth) { AccountInfo = accountInfo; }
public static bool CheckOAuth(OAuth2Info oauth) { return(oauth != null && !string.IsNullOrEmpty(oauth.Client_ID) && !string.IsNullOrEmpty(oauth.Client_Secret) && oauth.Token != null && !string.IsNullOrEmpty(oauth.Token.access_token)); }
public override bool CheckConfig(UploadersConfig config) { return(OAuth2Info.CheckOAuth(config.PicasaOAuth2Info)); }
public Hubic(OAuth2Info oauth, HubicOpenstackAuthInfo osauth) { AuthInfo = oauth; HubicOpenstackAuthInfo = osauth; }
public override bool CheckConfig(UploadersConfig config) { return(config.ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(config.ImgurOAuth2Info)); }
public GitHubGist(OAuth2Info oAuthInfos) { AuthInfo = oAuthInfos; }