本文整理汇总了C#中ShareX.UploadersLib.FileUploaders.GoogleDrive类的典型用法代码示例。如果您正苦于以下问题:C# GoogleDrive类的具体用法?C# GoogleDrive怎么用?C# GoogleDrive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GoogleDrive类属于ShareX.UploadersLib.FileUploaders命名空间,在下文中一共展示了GoogleDrive类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GoogleURLShortenerAuthRefresh
public void GoogleURLShortenerAuthRefresh()
{
try
{
if (OAuth2Info.CheckOAuth(Config.GoogleURLShortenerOAuth2Info))
{
bool result = new GoogleDrive(Config.GoogleURLShortenerOAuth2Info).RefreshAccessToken();
if (result)
{
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginSuccessful;
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginFailed;
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例2: GoogleDriveAuthOpen
public void GoogleDriveAuthOpen()
{
try
{
OAuth2Info oauth = new OAuth2Info(APIKeys.GoogleClientID, APIKeys.GoogleClientSecret);
string url = new GoogleDrive(oauth).GetAuthorizationURL();
if (!string.IsNullOrEmpty(url))
{
Config.GoogleDriveOAuth2Info = oauth;
URLHelpers.OpenURL(url);
DebugHelper.WriteLine("GoogleDriveAuthOpen - Authorization URL is opened: " + url);
}
else
{
DebugHelper.WriteLine("GoogleDriveAuthOpen - Authorization URL is empty.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例3: GoogleURLShortenerAuthComplete
public void GoogleURLShortenerAuthComplete(string code)
{
try
{
if (!string.IsNullOrEmpty(code) && Config.GoogleURLShortenerOAuth2Info != null)
{
bool result = new GoogleDrive(Config.GoogleURLShortenerOAuth2Info).GetAccessToken(code);
if (result)
{
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginSuccessful;
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
oauth2GoogleURLShortener.Status = OAuthLoginStatus.LoginFailed;
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例4: GoogleDriveRefreshFolders
private void GoogleDriveRefreshFolders()
{
try
{
lvGoogleDriveFoldersList.Items.Clear();
if (OAuth2Info.CheckOAuth(Config.GoogleDriveOAuth2Info))
{
var folders = new GoogleDrive(Config.GoogleDriveOAuth2Info).GetFolders();
if (folders != null)
{
foreach (var folder in folders)
{
ListViewItem lvi = new ListViewItem(folder.title);
lvi.SubItems.Add(folder.description);
lvi.Tag = folder;
lvGoogleDriveFoldersList.Items.Add(lvi);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例5: UploadFile
public UploadResult UploadFile(Stream stream, string fileName)
{
FileUploader fileUploader = null;
FileDestination fileDestination;
switch (Info.DataType)
{
case EDataType.Image:
fileDestination = Info.TaskSettings.ImageFileDestination;
break;
case EDataType.Text:
fileDestination = Info.TaskSettings.TextFileDestination;
break;
default:
case EDataType.File:
fileDestination = Info.TaskSettings.FileDestination;
break;
}
switch (fileDestination)
{
case FileDestination.Dropbox:
fileUploader = new Dropbox(Program.UploadersConfig.DropboxOAuth2Info, Program.UploadersConfig.DropboxAccountInfo)
{
UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(Program.UploadersConfig.DropboxUploadPath)),
AutoCreateShareableLink = Program.UploadersConfig.DropboxAutoCreateShareableLink,
ShareURLType = Program.UploadersConfig.DropboxURLType
};
break;
case FileDestination.OneDrive:
fileUploader = new OneDrive(Program.UploadersConfig.OneDriveOAuth2Info)
{
FolderID = Program.UploadersConfig.OneDriveSelectedFolder.id,
AutoCreateShareableLink = Program.UploadersConfig.OneDriveAutoCreateShareableLink
};
break;
case FileDestination.GoogleDrive:
fileUploader = new GoogleDrive(Program.UploadersConfig.GoogleDriveOAuth2Info)
{
IsPublic = Program.UploadersConfig.GoogleDriveIsPublic,
FolderID = Program.UploadersConfig.GoogleDriveUseFolder ? Program.UploadersConfig.GoogleDriveFolderID : null
};
break;
case FileDestination.Copy:
fileUploader = new Copy(Program.UploadersConfig.CopyOAuthInfo, Program.UploadersConfig.CopyAccountInfo)
{
UploadPath = NameParser.Parse(NameParserType.URL, Copy.TidyUploadPath(Program.UploadersConfig.CopyUploadPath)),
URLType = Program.UploadersConfig.CopyURLType
};
break;
/*case FileDestination.Hubic:
fileUploader = new Hubic(Program.UploadersConfig.HubicOAuth2Info, Program.UploadersConfig.HubicOpenstackAuthInfo)
{
SelectedFolder = Program.UploadersConfig.HubicSelectedFolder,
Publish = Program.UploadersConfig.HubicPublish
};
break;*/
case FileDestination.SendSpace:
fileUploader = new SendSpace(APIKeys.SendSpaceKey);
switch (Program.UploadersConfig.SendSpaceAccountType)
{
case AccountType.Anonymous:
SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey);
break;
case AccountType.User:
SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, Program.UploadersConfig.SendSpaceUsername, Program.UploadersConfig.SendSpacePassword);
break;
}
break;
case FileDestination.Minus:
fileUploader = new Minus(Program.UploadersConfig.MinusConfig, Program.UploadersConfig.MinusOAuth2Info);
break;
case FileDestination.Box:
fileUploader = new Box(Program.UploadersConfig.BoxOAuth2Info)
{
FolderID = Program.UploadersConfig.BoxSelectedFolder.id,
Share = Program.UploadersConfig.BoxShare
};
break;
case FileDestination.Gfycat:
fileUploader = new GfycatUploader();
break;
case FileDestination.Ge_tt:
fileUploader = new Ge_tt(APIKeys.Ge_ttKey)
{
AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken
};
break;
case FileDestination.Localhostr:
fileUploader = new Hostr(Program.UploadersConfig.LocalhostrEmail, Program.UploadersConfig.LocalhostrPassword)
{
DirectURL = Program.UploadersConfig.LocalhostrDirectURL
};
break;
case FileDestination.CustomFileUploader:
CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomFileUploaderSelected);
if (customUploader != null)
{
fileUploader = new CustomFileUploader(customUploader);
//.........这里部分代码省略.........
示例6: PicasaAuthRefresh
public void PicasaAuthRefresh()
{
try
{
if (OAuth2Info.CheckOAuth(Config.PicasaOAuth2Info))
{
bool result = new GoogleDrive(Config.PicasaOAuth2Info).RefreshAccessToken();
if (result)
{
oauth2Picasa.Status = OAuthLoginStatus.LoginSuccessful;
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "sharexl", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
oauth2Picasa.Status = OAuthLoginStatus.LoginFailed;
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "sharexl", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
btnPicasaRefreshAlbumList.Enabled = result;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例7: PicasaAuthComplete
public void PicasaAuthComplete(string code)
{
try
{
if (!string.IsNullOrEmpty(code) && Config.PicasaOAuth2Info != null)
{
bool result = new GoogleDrive(Config.PicasaOAuth2Info).GetAccessToken(code);
if (result)
{
oauth2Picasa.Status = OAuthLoginStatus.LoginSuccessful;
MessageBox.Show(Resources.UploadersConfigForm_Login_successful, "sharexl", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
oauth2Picasa.Status = OAuthLoginStatus.LoginFailed;
MessageBox.Show(Resources.UploadersConfigForm_Login_failed, "sharexl", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
btnPicasaRefreshAlbumList.Enabled = result;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), Resources.UploadersConfigForm_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例8: UploadFile
private UploadResult UploadFile(string ssPath)
{
FileUploader fileUploader = null;
switch (App.Settings.ProfileActive.ImageFileUploaderType)
{
case FileDestination.Dropbox:
fileUploader = new Dropbox(App.UploadersConfig.DropboxOAuth2Info, App.UploadersConfig.DropboxAccountInfo)
{
UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(App.UploadersConfig.DropboxUploadPath)),
AutoCreateShareableLink = App.UploadersConfig.DropboxAutoCreateShareableLink,
ShareURLType = App.UploadersConfig.DropboxURLType
};
break;
case FileDestination.Copy:
fileUploader = new Copy(App.UploadersConfig.CopyOAuthInfo, App.UploadersConfig.CopyAccountInfo)
{
UploadPath = NameParser.Parse(NameParserType.URL, Copy.TidyUploadPath(App.UploadersConfig.CopyUploadPath)),
URLType = App.UploadersConfig.CopyURLType
};
break;
case FileDestination.GoogleDrive:
fileUploader = new GoogleDrive(App.UploadersConfig.GoogleDriveOAuth2Info)
{
IsPublic = App.UploadersConfig.GoogleDriveIsPublic,
FolderID = App.UploadersConfig.GoogleDriveUseFolder ? App.UploadersConfig.GoogleDriveFolderID : null
};
break;
case FileDestination.SendSpace:
fileUploader = new SendSpace(APIKeys.SendSpaceKey);
switch (App.UploadersConfig.SendSpaceAccountType)
{
case AccountType.Anonymous:
SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey);
break;
case AccountType.User:
SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, App.UploadersConfig.SendSpaceUsername, App.UploadersConfig.SendSpacePassword);
break;
}
break;
case FileDestination.Minus:
fileUploader = new Minus(App.UploadersConfig.MinusConfig, App.UploadersConfig.MinusOAuth2Info);
break;
case FileDestination.Box:
fileUploader = new Box(App.UploadersConfig.BoxOAuth2Info)
{
FolderID = App.UploadersConfig.BoxSelectedFolder.id,
Share = App.UploadersConfig.BoxShare
};
break;
case FileDestination.Gfycat:
fileUploader = new GfycatUploader();
break;
case FileDestination.Ge_tt:
fileUploader = new Ge_tt(APIKeys.Ge_ttKey)
{
AccessToken = App.UploadersConfig.Ge_ttLogin.AccessToken
};
break;
case FileDestination.Localhostr:
fileUploader = new Hostr(App.UploadersConfig.LocalhostrEmail, App.UploadersConfig.LocalhostrPassword)
{
DirectURL = App.UploadersConfig.LocalhostrDirectURL
};
break;
case FileDestination.CustomFileUploader:
if (App.UploadersConfig.CustomUploadersList.IsValidIndex(App.UploadersConfig.CustomFileUploaderSelected))
{
fileUploader = new CustomFileUploader(App.UploadersConfig.CustomUploadersList[App.UploadersConfig.CustomFileUploaderSelected]);
}
break;
case FileDestination.FTP:
FTPAccount account = App.UploadersConfig.FTPAccountList.ReturnIfValidIndex(App.UploadersConfig.FTPSelectedImage);
if (account != null)
{
if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS)
{
fileUploader = new FTP(account);
}
else if (account.Protocol == FTPProtocol.SFTP)
{
fileUploader = new SFTP(account);
}
}
break;
case FileDestination.SharedFolder:
int idLocalhost = App.UploadersConfig.LocalhostSelectedImages;
if (App.UploadersConfig.LocalhostAccountList.IsValidIndex(idLocalhost))
{
fileUploader = new SharedFolderUploader(App.UploadersConfig.LocalhostAccountList[idLocalhost]);
}
break;
case FileDestination.Email:
using (EmailForm emailForm = new EmailForm(App.UploadersConfig.EmailRememberLastTo ? App.UploadersConfig.EmailLastTo : string.Empty,
App.UploadersConfig.EmailDefaultSubject, App.UploadersConfig.EmailDefaultBody))
{
emailForm.Icon = ShareXResources.Icon;
if (emailForm.ShowDialog() == DialogResult.OK)
//.........这里部分代码省略.........