mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
greenshot plugin for qiniu upload part 2
This commit is contained in:
parent
24c6c840fd
commit
2de30a902e
6 changed files with 255 additions and 75 deletions
87
GreenshotQiniuPlugin/Forms/SettingsForm.Designer.cs
generated
87
GreenshotQiniuPlugin/Forms/SettingsForm.Designer.cs
generated
|
@ -37,15 +37,18 @@
|
|||
this.gslblScope = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.buttonCancel = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.buttonOK = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.checkbox_usepagelink = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||
this.label_upload_format = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.combobox_uploadimageformat = new GreenshotPlugin.Controls.GreenshotComboBox();
|
||||
this.gstbDefaultDomain = new GreenshotPlugin.Controls.GreenshotTextBox();
|
||||
this.gslblDefaultDomain = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.gstbImageNamePrefix = new GreenshotPlugin.Controls.GreenshotTextBox();
|
||||
this.gslblImageNamePrefix = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// gslblAccessKey
|
||||
//
|
||||
this.gslblAccessKey.AutoSize = true;
|
||||
this.gslblAccessKey.Location = new System.Drawing.Point(18, 85);
|
||||
this.gslblAccessKey.Location = new System.Drawing.Point(18, 48);
|
||||
this.gslblAccessKey.Name = "gslblAccessKey";
|
||||
this.gslblAccessKey.Size = new System.Drawing.Size(65, 12);
|
||||
this.gslblAccessKey.TabIndex = 0;
|
||||
|
@ -53,26 +56,26 @@
|
|||
//
|
||||
// gstbAccessKey
|
||||
//
|
||||
this.gstbAccessKey.Location = new System.Drawing.Point(107, 85);
|
||||
this.gstbAccessKey.Location = new System.Drawing.Point(137, 48);
|
||||
this.gstbAccessKey.Name = "gstbAccessKey";
|
||||
this.gstbAccessKey.PropertyName = "AccessKey";
|
||||
this.gstbAccessKey.SectionName = "Qiniu";
|
||||
this.gstbAccessKey.Size = new System.Drawing.Size(261, 21);
|
||||
this.gstbAccessKey.Size = new System.Drawing.Size(241, 21);
|
||||
this.gstbAccessKey.TabIndex = 1;
|
||||
//
|
||||
// gstbSecretKey
|
||||
//
|
||||
this.gstbSecretKey.Location = new System.Drawing.Point(107, 116);
|
||||
this.gstbSecretKey.Location = new System.Drawing.Point(137, 79);
|
||||
this.gstbSecretKey.Name = "gstbSecretKey";
|
||||
this.gstbSecretKey.PropertyName = "SecretKey";
|
||||
this.gstbSecretKey.SectionName = "Qiniu";
|
||||
this.gstbSecretKey.Size = new System.Drawing.Size(261, 21);
|
||||
this.gstbSecretKey.Size = new System.Drawing.Size(241, 21);
|
||||
this.gstbSecretKey.TabIndex = 3;
|
||||
//
|
||||
// gslblSecretKey
|
||||
//
|
||||
this.gslblSecretKey.AutoSize = true;
|
||||
this.gslblSecretKey.Location = new System.Drawing.Point(18, 119);
|
||||
this.gslblSecretKey.Location = new System.Drawing.Point(18, 82);
|
||||
this.gslblSecretKey.Name = "gslblSecretKey";
|
||||
this.gslblSecretKey.Size = new System.Drawing.Size(65, 12);
|
||||
this.gslblSecretKey.TabIndex = 2;
|
||||
|
@ -80,17 +83,17 @@
|
|||
//
|
||||
// gstbScope
|
||||
//
|
||||
this.gstbScope.Location = new System.Drawing.Point(107, 148);
|
||||
this.gstbScope.Location = new System.Drawing.Point(137, 111);
|
||||
this.gstbScope.Name = "gstbScope";
|
||||
this.gstbScope.PropertyName = "Scope";
|
||||
this.gstbScope.SectionName = "Qiniu";
|
||||
this.gstbScope.Size = new System.Drawing.Size(261, 21);
|
||||
this.gstbScope.Size = new System.Drawing.Size(241, 21);
|
||||
this.gstbScope.TabIndex = 5;
|
||||
//
|
||||
// gslblScope
|
||||
//
|
||||
this.gslblScope.AutoSize = true;
|
||||
this.gslblScope.Location = new System.Drawing.Point(18, 151);
|
||||
this.gslblScope.Location = new System.Drawing.Point(18, 114);
|
||||
this.gslblScope.Name = "gslblScope";
|
||||
this.gslblScope.Size = new System.Drawing.Size(35, 12);
|
||||
this.gslblScope.TabIndex = 4;
|
||||
|
@ -120,19 +123,6 @@
|
|||
this.buttonOK.Text = "Ok";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkbox_usepagelink
|
||||
//
|
||||
this.checkbox_usepagelink.AutoSize = true;
|
||||
this.checkbox_usepagelink.LanguageKey = "Qiniu.use_page_link";
|
||||
this.checkbox_usepagelink.Location = new System.Drawing.Point(20, 48);
|
||||
this.checkbox_usepagelink.Name = "checkbox_usepagelink";
|
||||
this.checkbox_usepagelink.PropertyName = "UsePageLink";
|
||||
this.checkbox_usepagelink.SectionName = "Qiniu";
|
||||
this.checkbox_usepagelink.Size = new System.Drawing.Size(312, 16);
|
||||
this.checkbox_usepagelink.TabIndex = 14;
|
||||
this.checkbox_usepagelink.Text = "Use page link instead of image link on clipboard";
|
||||
this.checkbox_usepagelink.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label_upload_format
|
||||
//
|
||||
this.label_upload_format.LanguageKey = "Qiniu.label_upload_format";
|
||||
|
@ -146,19 +136,58 @@
|
|||
//
|
||||
this.combobox_uploadimageformat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.combobox_uploadimageformat.FormattingEnabled = true;
|
||||
this.combobox_uploadimageformat.Location = new System.Drawing.Point(107, 12);
|
||||
this.combobox_uploadimageformat.Location = new System.Drawing.Point(137, 12);
|
||||
this.combobox_uploadimageformat.Name = "combobox_uploadimageformat";
|
||||
this.combobox_uploadimageformat.PropertyName = "UploadFormat";
|
||||
this.combobox_uploadimageformat.SectionName = "Qiniu";
|
||||
this.combobox_uploadimageformat.Size = new System.Drawing.Size(261, 20);
|
||||
this.combobox_uploadimageformat.Size = new System.Drawing.Size(241, 20);
|
||||
this.combobox_uploadimageformat.TabIndex = 13;
|
||||
//
|
||||
// gstbDefaultDomain
|
||||
//
|
||||
this.gstbDefaultDomain.Location = new System.Drawing.Point(137, 144);
|
||||
this.gstbDefaultDomain.Name = "gstbDefaultDomain";
|
||||
this.gstbDefaultDomain.PropertyName = "DefaultDomain";
|
||||
this.gstbDefaultDomain.SectionName = "Qiniu";
|
||||
this.gstbDefaultDomain.Size = new System.Drawing.Size(241, 21);
|
||||
this.gstbDefaultDomain.TabIndex = 17;
|
||||
//
|
||||
// gslblDefaultDomain
|
||||
//
|
||||
this.gslblDefaultDomain.AutoSize = true;
|
||||
this.gslblDefaultDomain.Location = new System.Drawing.Point(18, 147);
|
||||
this.gslblDefaultDomain.Name = "gslblDefaultDomain";
|
||||
this.gslblDefaultDomain.Size = new System.Drawing.Size(89, 12);
|
||||
this.gslblDefaultDomain.TabIndex = 16;
|
||||
this.gslblDefaultDomain.Text = "Default Domain";
|
||||
//
|
||||
// gstbImageNamePrefix
|
||||
//
|
||||
this.gstbImageNamePrefix.Location = new System.Drawing.Point(137, 178);
|
||||
this.gstbImageNamePrefix.Name = "gstbImageNamePrefix";
|
||||
this.gstbImageNamePrefix.PropertyName = "ImageNamePrefix";
|
||||
this.gstbImageNamePrefix.SectionName = "Qiniu";
|
||||
this.gstbImageNamePrefix.Size = new System.Drawing.Size(241, 21);
|
||||
this.gstbImageNamePrefix.TabIndex = 19;
|
||||
//
|
||||
// gslblImageNamePrefix
|
||||
//
|
||||
this.gslblImageNamePrefix.AutoSize = true;
|
||||
this.gslblImageNamePrefix.Location = new System.Drawing.Point(18, 181);
|
||||
this.gslblImageNamePrefix.Name = "gslblImageNamePrefix";
|
||||
this.gslblImageNamePrefix.Size = new System.Drawing.Size(107, 12);
|
||||
this.gslblImageNamePrefix.TabIndex = 18;
|
||||
this.gslblImageNamePrefix.Text = "Image Name Prefix";
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(396, 243);
|
||||
this.Controls.Add(this.checkbox_usepagelink);
|
||||
this.Controls.Add(this.gstbImageNamePrefix);
|
||||
this.Controls.Add(this.gslblImageNamePrefix);
|
||||
this.Controls.Add(this.gstbDefaultDomain);
|
||||
this.Controls.Add(this.gslblDefaultDomain);
|
||||
this.Controls.Add(this.label_upload_format);
|
||||
this.Controls.Add(this.combobox_uploadimageformat);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
|
@ -173,6 +202,7 @@
|
|||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SettingsForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Qiniu image upload settings";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
@ -189,8 +219,11 @@
|
|||
private GreenshotPlugin.Controls.GreenshotLabel gslblScope;
|
||||
private GreenshotPlugin.Controls.GreenshotButton buttonCancel;
|
||||
private GreenshotPlugin.Controls.GreenshotButton buttonOK;
|
||||
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_usepagelink;
|
||||
private GreenshotPlugin.Controls.GreenshotLabel label_upload_format;
|
||||
private GreenshotPlugin.Controls.GreenshotComboBox combobox_uploadimageformat;
|
||||
private GreenshotPlugin.Controls.GreenshotTextBox gstbDefaultDomain;
|
||||
private GreenshotPlugin.Controls.GreenshotLabel gslblDefaultDomain;
|
||||
private GreenshotPlugin.Controls.GreenshotTextBox gstbImageNamePrefix;
|
||||
private GreenshotPlugin.Controls.GreenshotLabel gslblImageNamePrefix;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<language description="English" ietf="en-US" version="1.0.0" prefix="Qiniu">
|
||||
<language description="English" ietf="en-US" version="1.0.0" prefix="qiniu">
|
||||
<resources>
|
||||
<resource name="upload_menu_item">
|
||||
Upload to Qiniu
|
||||
</resource>
|
||||
<resource name="settings_title">
|
||||
Imgur settings
|
||||
Qiniu settings
|
||||
</resource>
|
||||
<resource name="label_url">
|
||||
Url
|
||||
|
@ -17,25 +17,25 @@
|
|||
Cancel
|
||||
</resource>
|
||||
<resource name="upload_success">
|
||||
Successfully uploaded image to Imgur!
|
||||
Successfully uploaded image to Qiniu!
|
||||
</resource>
|
||||
<resource name="upload_failure">
|
||||
An error occured while uploading to Imgur:
|
||||
An error occured while uploading to Qiniu:
|
||||
</resource>
|
||||
<resource name="label_upload_format">
|
||||
Image format
|
||||
</resource>
|
||||
<resource name="communication_wait">
|
||||
Communicating with Imgur. Please wait...
|
||||
Communicating with Qiniu. Please wait...
|
||||
</resource>
|
||||
<resource name="delete_question">
|
||||
Are you sure you want to delete the image {0} from Imgur?
|
||||
Are you sure you want to delete the image {0} from Qiniu?
|
||||
</resource>
|
||||
<resource name="clear_question">
|
||||
Are you sure you want to delete the local Imgur history?
|
||||
Are you sure you want to delete the local Qiniu history?
|
||||
</resource>
|
||||
<resource name="delete_title">
|
||||
Delete Imgur {0}
|
||||
Delete Qiniu {0}
|
||||
</resource>
|
||||
<resource name="anonymous_access">
|
||||
Use anonymous access
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<language description="简体中文" ietf="zh-CN" version="1.0.2" languagegroup="a" prefix="Qiniu">
|
||||
<language description="简体中文" ietf="zh-CN" version="1.0.2" languagegroup="a" prefix="qiniu">
|
||||
<resources>
|
||||
<resource name="anonymous_access">使用匿名连接</resource>
|
||||
<resource name="CANCEL">取消</resource>
|
||||
|
|
|
@ -36,13 +36,8 @@ namespace GreenshotQiniuPlugin
|
|||
public int UploadJpegQuality { get; set; }
|
||||
[IniProperty("UploadReduceColors", Description = "Reduce color amount of the uploaded image to 256", DefaultValue = "False")]
|
||||
public bool UploadReduceColors { get; set; }
|
||||
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
|
||||
public bool UsePageLink { get; set; }
|
||||
|
||||
|
||||
[IniProperty("ImgQiniuUrl", Description = "Url to Qiniu cloud.", DefaultValue = "")]
|
||||
public string ImgQiniuUrl { get; set; }
|
||||
|
||||
[IniProperty("AccessKey", Description = "access key used for uploading", DefaultValue = "")]
|
||||
public string AccessKey { get; set; }
|
||||
|
||||
|
@ -51,8 +46,14 @@ namespace GreenshotQiniuPlugin
|
|||
|
||||
[IniProperty("Scope", Description = "scope key used for uploading", DefaultValue = "")]
|
||||
public string Scope { get; set; }
|
||||
|
||||
|
||||
|
||||
[IniProperty("DefaultDomain", Description = "default domain name of qiniu for specified scope", DefaultValue = "www.qiniu.com")]
|
||||
public string DefaultDomain { get; set; }
|
||||
|
||||
[IniProperty("ImageNamePrefix", Description = "set Image Name Prefix ", DefaultValue = "prefix_")]
|
||||
public string ImageNamePrefix { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A form for username/password
|
||||
/// </summary>
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace GreenshotQiniuPlugin
|
|||
// Get configuration
|
||||
_config = IniConfig.GetIniSection<QiniuConfiguration>();
|
||||
_resources = new ComponentResourceManager(typeof(QiniuPlugin));
|
||||
string text = Language.GetString("Qiniu", LangKey.configure);
|
||||
string text = Language.GetString("qiniu", LangKey.configure);
|
||||
_itemPlugInConfig = new ToolStripMenuItem(text)
|
||||
{
|
||||
Tag = _host,
|
||||
|
@ -138,10 +138,9 @@ namespace GreenshotQiniuPlugin
|
|||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(_config.UploadFormat, _config.UploadJpegQuality, _config.UploadReduceColors);
|
||||
try
|
||||
{
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
|
||||
QiniuInfo qiniuInfo = null;
|
||||
|
||||
|
||||
string filename = _config.ImageNamePrefix + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + _config.UploadFormat.ToString().ToLower();
|
||||
Path.GetFileName(FilenameHelper.GetFilename(_config.UploadFormat, captureDetails));
|
||||
|
||||
string path = Directory.GetCurrentDirectory();
|
||||
|
||||
string fullPath = Path.Combine(path, filename);
|
||||
|
@ -149,39 +148,29 @@ namespace GreenshotQiniuPlugin
|
|||
// public static void Save(ISurface surface, string fullPath, bool allowOverwrite, SurfaceOutputSettings outputSettings, bool copyPathToClipboard)
|
||||
// Run upload in the background
|
||||
ImageOutput.Save(surfaceToUpload,fullPath,true,outputSettings,true);
|
||||
//new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("Qiniu", LangKey.communication_wait),
|
||||
// delegate
|
||||
// {
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("qiniu", LangKey.communication_wait),
|
||||
delegate
|
||||
{
|
||||
HttpResult result = QiniuUtils.UploadFile(fullPath,filename);
|
||||
|
||||
//}
|
||||
//);
|
||||
}
|
||||
);
|
||||
// This causes an exeption if the upload failed :)
|
||||
Log.DebugFormat("Uploaded to qiniu page: " + qiniuInfo.Page);
|
||||
uploadUrl = null;
|
||||
try
|
||||
{
|
||||
if (_config.UsePageLink)
|
||||
{
|
||||
uploadUrl = qiniuInfo.Page;
|
||||
Clipboard.SetText(qiniuInfo.Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
uploadUrl = qiniuInfo.Original;
|
||||
Clipboard.SetText(qiniuInfo.Original);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Can't write to clipboard: ", ex);
|
||||
}
|
||||
//Log.DebugFormat("Uploaded to qiniu page: " + qiniuInfo.Page);
|
||||
|
||||
uploadUrl = _config.DefaultDomain + filename;
|
||||
|
||||
|
||||
Clipboard.SetText(uploadUrl);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
MessageBox.Show(Language.GetString("Qiniu", LangKey.upload_failure) + " " + e.Message);
|
||||
MessageBox.Show(Language.GetString("qiniu", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
uploadUrl = null;
|
||||
return false;
|
||||
|
|
|
@ -34,6 +34,8 @@ using Qiniu.IO.Model;
|
|||
using Qiniu.Http;
|
||||
using Qiniu.Util;
|
||||
|
||||
|
||||
|
||||
namespace GreenshotQiniuPlugin
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -42,8 +44,157 @@ namespace GreenshotQiniuPlugin
|
|||
public static class QiniuUtils {
|
||||
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(QiniuUtils));
|
||||
private static readonly QiniuConfiguration _config = IniConfig.GetIniSection<QiniuConfiguration>();
|
||||
public enum HttpCode
|
||||
{
|
||||
#region _PRE_
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
OK = 200,
|
||||
|
||||
/// <summary>
|
||||
/// 部分OK
|
||||
/// </summary>
|
||||
PARTLY_OK = 298,
|
||||
|
||||
/// <summary>
|
||||
/// 请求错误
|
||||
/// </summary>
|
||||
BAD_REQUEST = 400,
|
||||
|
||||
/// <summary>
|
||||
/// 认证授权失败
|
||||
/// </summary>
|
||||
AUTHENTICATION_FAILED = 401,
|
||||
|
||||
/// <summary>
|
||||
/// 拒绝访问
|
||||
/// </summary>
|
||||
ACCESS_DENIED = 403,
|
||||
|
||||
/// <summary>
|
||||
/// 资源不存在
|
||||
/// </summary>
|
||||
OBJECT_NOT_FOUND = 404,
|
||||
|
||||
/// <summary>
|
||||
/// CRC32校验失败
|
||||
/// </summary>
|
||||
CRC32_CHECK_FAILEd = 406,
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件大小超限
|
||||
/// </summary>
|
||||
FILE_SIZE_EXCEED = 413,
|
||||
|
||||
/// <summary>
|
||||
/// 镜像回源失败
|
||||
/// </summary>
|
||||
PREFETCH_FAILED = 478,
|
||||
|
||||
/// <summary>
|
||||
/// 错误网关
|
||||
/// </summary>
|
||||
BAD_GATEWAY = 502,
|
||||
|
||||
/// <summary>
|
||||
/// 服务端不可用
|
||||
/// </summary>
|
||||
SERVER_UNAVAILABLE = 503,
|
||||
|
||||
/// <summary>
|
||||
/// 服务端操作超时
|
||||
/// </summary>
|
||||
SERVER_TIME_EXCEED = 504,
|
||||
|
||||
/// <summary>
|
||||
/// 单个资源访问频率过高
|
||||
/// </summary>
|
||||
TOO_FREQUENT_ACCESS = 573,
|
||||
|
||||
/// <summary>
|
||||
/// 回调失败
|
||||
/// </summary>
|
||||
CALLBACK_FAILED = 579,
|
||||
|
||||
/// <summary>
|
||||
/// 服务端操作失败
|
||||
/// </summary>
|
||||
SERVER_OPERATION_FAILED = 599,
|
||||
|
||||
/// <summary>
|
||||
/// 资源内容被修改
|
||||
/// </summary>
|
||||
CONTENT_MODIFIED = 608,
|
||||
|
||||
/// <summary>
|
||||
/// 文件不存在
|
||||
/// </summary>
|
||||
FILE_NOT_EXIST = 612,
|
||||
|
||||
/// <summary>
|
||||
/// 文件已存在
|
||||
/// </summary>
|
||||
FILE_EXISTS = 614,
|
||||
|
||||
/// <summary>
|
||||
/// 空间数量已达上限
|
||||
/// </summary>
|
||||
BUCKET_COUNT_LIMIT = 630,
|
||||
|
||||
/// <summary>
|
||||
/// 空间或者文件不存在
|
||||
/// </summary>
|
||||
BUCKET_NOT_EXIST = 631,
|
||||
|
||||
/// <summary>
|
||||
/// 列举资源(list)使用了非法的marker
|
||||
/// </summary>
|
||||
INVALID_MARKER = 640,
|
||||
|
||||
/// <summary>
|
||||
/// 在断点续上传过程中,后续上传接收地址不正确或ctx信息已过期。
|
||||
/// </summary>
|
||||
CONTEXT_EXPIRED = 701,
|
||||
|
||||
#endregion _PRE_
|
||||
|
||||
#region _USR_
|
||||
|
||||
/// <summary>
|
||||
/// 自定义HTTP状态码 (默认值)
|
||||
/// </summary>
|
||||
USER_UNDEF = -256,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义HTTP状态码 (用户取消)
|
||||
/// </summary>
|
||||
USER_CANCELED = -255,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义HTTP状态码 (用户暂停)
|
||||
/// </summary>
|
||||
USER_PAUSED = -254,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义HTTP状态码 (用户继续)
|
||||
/// </summary>
|
||||
USER_RESUMED = -253,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义HTTP状态码 (需要重试)
|
||||
/// </summary>
|
||||
USER_NEED_RETRY = -252,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义HTTP状态码 (异常或错误)
|
||||
/// </summary>
|
||||
USER_EXCEPTION = -252,
|
||||
|
||||
#endregion _USR_
|
||||
|
||||
}
|
||||
|
||||
public static HttpResult UploadFile(string fullPath,string fileName)
|
||||
{
|
||||
|
@ -56,7 +207,13 @@ namespace GreenshotQiniuPlugin
|
|||
|
||||
ResumableUploader target = new ResumableUploader();
|
||||
HttpResult result = target.UploadFile(fullPath, fileName, token);
|
||||
File.Delete(fullPath);
|
||||
if (result.Code != (int)HttpCode.OK)
|
||||
{
|
||||
File.Delete(fullPath);
|
||||
Log.Error(result.Text);
|
||||
throw new Exception(result.Text);
|
||||
}
|
||||
File.Delete(fullPath);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue