mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 14:24:43 -07:00
use dll by nuget;fix bug;add Zone
This commit is contained in:
parent
27436f4571
commit
e6462f9d80
6 changed files with 115 additions and 49 deletions
52
GreenshotQiniuPlugin/Forms/SettingsForm.Designer.cs
generated
52
GreenshotQiniuPlugin/Forms/SettingsForm.Designer.cs
generated
|
@ -43,12 +43,14 @@
|
||||||
this.gslblDefaultDomain = new GreenshotPlugin.Controls.GreenshotLabel();
|
this.gslblDefaultDomain = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||||
this.gstbImageNamePrefix = new GreenshotPlugin.Controls.GreenshotTextBox();
|
this.gstbImageNamePrefix = new GreenshotPlugin.Controls.GreenshotTextBox();
|
||||||
this.gslblImageNamePrefix = new GreenshotPlugin.Controls.GreenshotLabel();
|
this.gslblImageNamePrefix = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||||
|
this.gslblZone = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||||
|
this.gscobZone = new GreenshotPlugin.Controls.GreenshotComboBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// gslblAccessKey
|
// gslblAccessKey
|
||||||
//
|
//
|
||||||
this.gslblAccessKey.AutoSize = true;
|
this.gslblAccessKey.AutoSize = true;
|
||||||
this.gslblAccessKey.Location = new System.Drawing.Point(18, 48);
|
this.gslblAccessKey.Location = new System.Drawing.Point(18, 79);
|
||||||
this.gslblAccessKey.Name = "gslblAccessKey";
|
this.gslblAccessKey.Name = "gslblAccessKey";
|
||||||
this.gslblAccessKey.Size = new System.Drawing.Size(65, 12);
|
this.gslblAccessKey.Size = new System.Drawing.Size(65, 12);
|
||||||
this.gslblAccessKey.TabIndex = 0;
|
this.gslblAccessKey.TabIndex = 0;
|
||||||
|
@ -56,7 +58,7 @@
|
||||||
//
|
//
|
||||||
// gstbAccessKey
|
// gstbAccessKey
|
||||||
//
|
//
|
||||||
this.gstbAccessKey.Location = new System.Drawing.Point(137, 48);
|
this.gstbAccessKey.Location = new System.Drawing.Point(137, 79);
|
||||||
this.gstbAccessKey.Name = "gstbAccessKey";
|
this.gstbAccessKey.Name = "gstbAccessKey";
|
||||||
this.gstbAccessKey.PropertyName = "AccessKey";
|
this.gstbAccessKey.PropertyName = "AccessKey";
|
||||||
this.gstbAccessKey.SectionName = "Qiniu";
|
this.gstbAccessKey.SectionName = "Qiniu";
|
||||||
|
@ -65,7 +67,7 @@
|
||||||
//
|
//
|
||||||
// gstbSecretKey
|
// gstbSecretKey
|
||||||
//
|
//
|
||||||
this.gstbSecretKey.Location = new System.Drawing.Point(137, 79);
|
this.gstbSecretKey.Location = new System.Drawing.Point(137, 113);
|
||||||
this.gstbSecretKey.Name = "gstbSecretKey";
|
this.gstbSecretKey.Name = "gstbSecretKey";
|
||||||
this.gstbSecretKey.PropertyName = "SecretKey";
|
this.gstbSecretKey.PropertyName = "SecretKey";
|
||||||
this.gstbSecretKey.SectionName = "Qiniu";
|
this.gstbSecretKey.SectionName = "Qiniu";
|
||||||
|
@ -75,7 +77,7 @@
|
||||||
// gslblSecretKey
|
// gslblSecretKey
|
||||||
//
|
//
|
||||||
this.gslblSecretKey.AutoSize = true;
|
this.gslblSecretKey.AutoSize = true;
|
||||||
this.gslblSecretKey.Location = new System.Drawing.Point(18, 82);
|
this.gslblSecretKey.Location = new System.Drawing.Point(18, 116);
|
||||||
this.gslblSecretKey.Name = "gslblSecretKey";
|
this.gslblSecretKey.Name = "gslblSecretKey";
|
||||||
this.gslblSecretKey.Size = new System.Drawing.Size(65, 12);
|
this.gslblSecretKey.Size = new System.Drawing.Size(65, 12);
|
||||||
this.gslblSecretKey.TabIndex = 2;
|
this.gslblSecretKey.TabIndex = 2;
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
//
|
//
|
||||||
// gstbScope
|
// gstbScope
|
||||||
//
|
//
|
||||||
this.gstbScope.Location = new System.Drawing.Point(137, 111);
|
this.gstbScope.Location = new System.Drawing.Point(137, 147);
|
||||||
this.gstbScope.Name = "gstbScope";
|
this.gstbScope.Name = "gstbScope";
|
||||||
this.gstbScope.PropertyName = "Scope";
|
this.gstbScope.PropertyName = "Scope";
|
||||||
this.gstbScope.SectionName = "Qiniu";
|
this.gstbScope.SectionName = "Qiniu";
|
||||||
|
@ -93,7 +95,7 @@
|
||||||
// gslblScope
|
// gslblScope
|
||||||
//
|
//
|
||||||
this.gslblScope.AutoSize = true;
|
this.gslblScope.AutoSize = true;
|
||||||
this.gslblScope.Location = new System.Drawing.Point(18, 114);
|
this.gslblScope.Location = new System.Drawing.Point(18, 150);
|
||||||
this.gslblScope.Name = "gslblScope";
|
this.gslblScope.Name = "gslblScope";
|
||||||
this.gslblScope.Size = new System.Drawing.Size(35, 12);
|
this.gslblScope.Size = new System.Drawing.Size(35, 12);
|
||||||
this.gslblScope.TabIndex = 4;
|
this.gslblScope.TabIndex = 4;
|
||||||
|
@ -104,7 +106,7 @@
|
||||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
this.buttonCancel.LanguageKey = "CANCEL";
|
this.buttonCancel.LanguageKey = "CANCEL";
|
||||||
this.buttonCancel.Location = new System.Drawing.Point(294, 208);
|
this.buttonCancel.Location = new System.Drawing.Point(294, 248);
|
||||||
this.buttonCancel.Name = "buttonCancel";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonCancel.TabIndex = 7;
|
this.buttonCancel.TabIndex = 7;
|
||||||
|
@ -116,7 +118,7 @@
|
||||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||||
this.buttonOK.LanguageKey = "OK";
|
this.buttonOK.LanguageKey = "OK";
|
||||||
this.buttonOK.Location = new System.Drawing.Point(213, 208);
|
this.buttonOK.Location = new System.Drawing.Point(213, 248);
|
||||||
this.buttonOK.Name = "buttonOK";
|
this.buttonOK.Name = "buttonOK";
|
||||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonOK.TabIndex = 6;
|
this.buttonOK.TabIndex = 6;
|
||||||
|
@ -145,7 +147,7 @@
|
||||||
//
|
//
|
||||||
// gstbDefaultDomain
|
// gstbDefaultDomain
|
||||||
//
|
//
|
||||||
this.gstbDefaultDomain.Location = new System.Drawing.Point(137, 144);
|
this.gstbDefaultDomain.Location = new System.Drawing.Point(137, 180);
|
||||||
this.gstbDefaultDomain.Name = "gstbDefaultDomain";
|
this.gstbDefaultDomain.Name = "gstbDefaultDomain";
|
||||||
this.gstbDefaultDomain.PropertyName = "DefaultDomain";
|
this.gstbDefaultDomain.PropertyName = "DefaultDomain";
|
||||||
this.gstbDefaultDomain.SectionName = "Qiniu";
|
this.gstbDefaultDomain.SectionName = "Qiniu";
|
||||||
|
@ -155,7 +157,7 @@
|
||||||
// gslblDefaultDomain
|
// gslblDefaultDomain
|
||||||
//
|
//
|
||||||
this.gslblDefaultDomain.AutoSize = true;
|
this.gslblDefaultDomain.AutoSize = true;
|
||||||
this.gslblDefaultDomain.Location = new System.Drawing.Point(18, 147);
|
this.gslblDefaultDomain.Location = new System.Drawing.Point(18, 183);
|
||||||
this.gslblDefaultDomain.Name = "gslblDefaultDomain";
|
this.gslblDefaultDomain.Name = "gslblDefaultDomain";
|
||||||
this.gslblDefaultDomain.Size = new System.Drawing.Size(89, 12);
|
this.gslblDefaultDomain.Size = new System.Drawing.Size(89, 12);
|
||||||
this.gslblDefaultDomain.TabIndex = 16;
|
this.gslblDefaultDomain.TabIndex = 16;
|
||||||
|
@ -163,7 +165,7 @@
|
||||||
//
|
//
|
||||||
// gstbImageNamePrefix
|
// gstbImageNamePrefix
|
||||||
//
|
//
|
||||||
this.gstbImageNamePrefix.Location = new System.Drawing.Point(137, 178);
|
this.gstbImageNamePrefix.Location = new System.Drawing.Point(137, 214);
|
||||||
this.gstbImageNamePrefix.Name = "gstbImageNamePrefix";
|
this.gstbImageNamePrefix.Name = "gstbImageNamePrefix";
|
||||||
this.gstbImageNamePrefix.PropertyName = "ImageNamePrefix";
|
this.gstbImageNamePrefix.PropertyName = "ImageNamePrefix";
|
||||||
this.gstbImageNamePrefix.SectionName = "Qiniu";
|
this.gstbImageNamePrefix.SectionName = "Qiniu";
|
||||||
|
@ -173,17 +175,39 @@
|
||||||
// gslblImageNamePrefix
|
// gslblImageNamePrefix
|
||||||
//
|
//
|
||||||
this.gslblImageNamePrefix.AutoSize = true;
|
this.gslblImageNamePrefix.AutoSize = true;
|
||||||
this.gslblImageNamePrefix.Location = new System.Drawing.Point(18, 181);
|
this.gslblImageNamePrefix.Location = new System.Drawing.Point(18, 217);
|
||||||
this.gslblImageNamePrefix.Name = "gslblImageNamePrefix";
|
this.gslblImageNamePrefix.Name = "gslblImageNamePrefix";
|
||||||
this.gslblImageNamePrefix.Size = new System.Drawing.Size(107, 12);
|
this.gslblImageNamePrefix.Size = new System.Drawing.Size(107, 12);
|
||||||
this.gslblImageNamePrefix.TabIndex = 18;
|
this.gslblImageNamePrefix.TabIndex = 18;
|
||||||
this.gslblImageNamePrefix.Text = "Image Name Prefix";
|
this.gslblImageNamePrefix.Text = "Image Name Prefix";
|
||||||
//
|
//
|
||||||
|
// gslblZone
|
||||||
|
//
|
||||||
|
this.gslblZone.AutoSize = true;
|
||||||
|
this.gslblZone.Location = new System.Drawing.Point(18, 48);
|
||||||
|
this.gslblZone.Name = "gslblZone";
|
||||||
|
this.gslblZone.Size = new System.Drawing.Size(29, 12);
|
||||||
|
this.gslblZone.TabIndex = 22;
|
||||||
|
this.gslblZone.Text = "Zone";
|
||||||
|
//
|
||||||
|
// gscobZone
|
||||||
|
//
|
||||||
|
this.gscobZone.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.gscobZone.FormattingEnabled = true;
|
||||||
|
this.gscobZone.Location = new System.Drawing.Point(137, 48);
|
||||||
|
this.gscobZone.Name = "gscobZone";
|
||||||
|
this.gscobZone.PropertyName = "Zone";
|
||||||
|
this.gscobZone.SectionName = "Qiniu";
|
||||||
|
this.gscobZone.Size = new System.Drawing.Size(241, 20);
|
||||||
|
this.gscobZone.TabIndex = 23;
|
||||||
|
//
|
||||||
// SettingsForm
|
// SettingsForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(396, 243);
|
this.ClientSize = new System.Drawing.Size(396, 283);
|
||||||
|
this.Controls.Add(this.gscobZone);
|
||||||
|
this.Controls.Add(this.gslblZone);
|
||||||
this.Controls.Add(this.gstbImageNamePrefix);
|
this.Controls.Add(this.gstbImageNamePrefix);
|
||||||
this.Controls.Add(this.gslblImageNamePrefix);
|
this.Controls.Add(this.gslblImageNamePrefix);
|
||||||
this.Controls.Add(this.gstbDefaultDomain);
|
this.Controls.Add(this.gstbDefaultDomain);
|
||||||
|
@ -225,5 +249,7 @@
|
||||||
private GreenshotPlugin.Controls.GreenshotLabel gslblDefaultDomain;
|
private GreenshotPlugin.Controls.GreenshotLabel gslblDefaultDomain;
|
||||||
private GreenshotPlugin.Controls.GreenshotTextBox gstbImageNamePrefix;
|
private GreenshotPlugin.Controls.GreenshotTextBox gstbImageNamePrefix;
|
||||||
private GreenshotPlugin.Controls.GreenshotLabel gslblImageNamePrefix;
|
private GreenshotPlugin.Controls.GreenshotLabel gslblImageNamePrefix;
|
||||||
|
private GreenshotPlugin.Controls.GreenshotLabel gslblZone;
|
||||||
|
private GreenshotPlugin.Controls.GreenshotComboBox gscobZone;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,6 +28,7 @@
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Accessibility" />
|
<Reference Include="Accessibility" />
|
||||||
|
@ -37,12 +38,11 @@
|
||||||
<Reference Include="log4net">
|
<Reference Include="log4net">
|
||||||
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
|
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
<HintPath>..\..\csharp-sdk\src\packages\Newtonsoft.Json.10.0.2\lib\net20\Newtonsoft.Json.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Qiniu">
|
<Reference Include="Qiniu, Version=7.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\csharp-sdk\bin\Qiniu.dll</HintPath>
|
<HintPath>..\packages\Qiniu.7.3.0\lib\Net40\Qiniu.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -92,28 +92,31 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Languages\language_qiniuplugin-en-US.xml" />
|
<Content Include="Languages\language_qiniuplugin-en-US.xml" />
|
||||||
<Content Include="Languages\language_qiniuplugin-zh-CN.xml" />
|
<Content Include="Languages\language_qiniuplugin-zh-CN.xml" />
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Resources\Qiniu.bmp" />
|
<None Include="Resources\Qiniu.bmp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
if exist "$(ProjectDir)QiniuCredentials.private.cs" (
|
</PreBuildEvent>
|
||||||
rename "$(ProjectDir)QiniuCredentials.cs" "QiniuCredentials.orig.cs"
|
|
||||||
rename "$(ProjectDir)QiniuCredentials.private.cs" "QiniuCredentials.cs"
|
|
||||||
)
|
|
||||||
</PreBuildEvent>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
||||||
if exist "$(ProjectDir)QiniuCredentials.orig.cs" (
|
"$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
|
||||||
rename "$(ProjectDir)QiniuCredentials.cs" "QiniuCredentials.private.cs"
|
del /q /s "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"\*
|
||||||
rename "$(ProjectDir)QiniuCredentials.orig.cs" "QiniuCredentials.cs"
|
|
||||||
|
if "$(ConfigurationName)" == "Release" (
|
||||||
|
..\..\..\packages\LibZ.Tool.1.2.0.0\tools\libz.exe inject-dll --assembly $(ProjectDir)bin\$(Configuration)\$(TargetFileName) --include $(ProjectDir)bin\$(Configuration)\Qiniu.dll --include $(ProjectDir)bin\$(Configuration)\Newtonsoft.Json.dll --move
|
||||||
)
|
)
|
||||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)"
|
|
||||||
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
|
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
|
||||||
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
|
||||||
|
if "$(ConfigurationName)" == "Debug" (
|
||||||
|
copy "$(ProjectDir)bin\$(Configuration)\Qiniu.dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||||
|
copy "$(ProjectDir)bin\$(Configuration)\Newtonsoft.Json.dll" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||||
|
copy "$(ProjectDir)bin\$(Configuration)\$(ProjectName).pdb" "$(SolutionDir)Greenshot\bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||||
|
)
|
||||||
|
|
||||||
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
mkdir "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
|
||||||
</PostBuildEvent>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -37,6 +37,18 @@ namespace GreenshotQiniuPlugin
|
||||||
[IniProperty("UploadReduceColors", Description = "Reduce color amount of the uploaded image to 256", DefaultValue = "False")]
|
[IniProperty("UploadReduceColors", Description = "Reduce color amount of the uploaded image to 256", DefaultValue = "False")]
|
||||||
public bool UploadReduceColors { get; set; }
|
public bool UploadReduceColors { get; set; }
|
||||||
|
|
||||||
|
/*public static Zone ZONE_CN_East;
|
||||||
|
public static Zone ZONE_CN_North;
|
||||||
|
public static Zone ZONE_CN_South;
|
||||||
|
public static Zone ZONE_US_North;
|
||||||
|
*/
|
||||||
|
|
||||||
|
public enum UploadZone
|
||||||
|
{
|
||||||
|
CN_North, CN_East, CN_South, US_North
|
||||||
|
}
|
||||||
|
[IniProperty("Zone", Description = "Zone used for uploading", DefaultValue = "CN_North")]
|
||||||
|
public UploadZone Zone { get; set; }
|
||||||
|
|
||||||
[IniProperty("AccessKey", Description = "access key used for uploading", DefaultValue = "")]
|
[IniProperty("AccessKey", Description = "access key used for uploading", DefaultValue = "")]
|
||||||
public string AccessKey { get; set; }
|
public string AccessKey { get; set; }
|
||||||
|
|
|
@ -28,9 +28,7 @@ using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
using Qiniu.Common;
|
|
||||||
using Qiniu.IO;
|
|
||||||
using Qiniu.IO.Model;
|
|
||||||
using Qiniu.Http;
|
using Qiniu.Http;
|
||||||
using Qiniu.Util;
|
using Qiniu.Util;
|
||||||
|
|
||||||
|
@ -147,21 +145,23 @@ namespace GreenshotQiniuPlugin
|
||||||
|
|
||||||
// public static void Save(ISurface surface, string fullPath, bool allowOverwrite, SurfaceOutputSettings outputSettings, bool copyPathToClipboard)
|
// public static void Save(ISurface surface, string fullPath, bool allowOverwrite, SurfaceOutputSettings outputSettings, bool copyPathToClipboard)
|
||||||
// Run upload in the background
|
// Run upload in the background
|
||||||
ImageOutput.Save(surfaceToUpload,fullPath,true,outputSettings,true);
|
MemoryStream streamoutput = new MemoryStream();
|
||||||
|
ImageOutput.SaveToStream(surfaceToUpload, streamoutput, outputSettings);
|
||||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("qiniu", LangKey.communication_wait),
|
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("qiniu", LangKey.communication_wait),
|
||||||
delegate
|
delegate
|
||||||
{
|
{
|
||||||
HttpResult result = QiniuUtils.UploadFile(fullPath,filename);
|
HttpResult result = QiniuUtils.UploadFile(streamoutput, filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// This causes an exeption if the upload failed :)
|
// This causes an exeption if the upload failed :)
|
||||||
//Log.DebugFormat("Uploaded to qiniu page: " + qiniuInfo.Page);
|
//Log.DebugFormat("Uploaded to qiniu page: " + qiniuInfo.Page);
|
||||||
|
|
||||||
uploadUrl = "";
|
uploadUrl = _config.DefaultDomain + filename;
|
||||||
|
|
||||||
|
string markdownURL = "";
|
||||||
|
|
||||||
|
|
||||||
Clipboard.SetText(uploadUrl);
|
Clipboard.SetText(markdownURL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,9 @@ using Greenshot.IniFile;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
|
|
||||||
using Qiniu.Common;
|
|
||||||
using Qiniu.IO;
|
|
||||||
using Qiniu.IO.Model;
|
|
||||||
using Qiniu.Http;
|
using Qiniu.Http;
|
||||||
using Qiniu.Util;
|
using Qiniu.Util;
|
||||||
|
using Qiniu.Storage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -196,7 +194,7 @@ namespace GreenshotQiniuPlugin
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpResult UploadFile(string fullPath,string fileName)
|
public static HttpResult UploadFile(Stream filestream,string fileName)
|
||||||
{
|
{
|
||||||
Mac mac = new Mac(_config.AccessKey, _config.SecretKey);
|
Mac mac = new Mac(_config.AccessKey, _config.SecretKey);
|
||||||
PutPolicy putPolicy = new PutPolicy();
|
PutPolicy putPolicy = new PutPolicy();
|
||||||
|
@ -205,15 +203,37 @@ namespace GreenshotQiniuPlugin
|
||||||
//putPolicy.DeleteAfterDays = 1;
|
//putPolicy.DeleteAfterDays = 1;
|
||||||
string token = Auth.CreateUploadToken(mac, putPolicy.ToJsonString());
|
string token = Auth.CreateUploadToken(mac, putPolicy.ToJsonString());
|
||||||
|
|
||||||
ResumableUploader target = new ResumableUploader();
|
Config config = new Config();
|
||||||
HttpResult result = target.UploadFile(fullPath, fileName, token);
|
// 设置上传区域
|
||||||
|
switch (_config.Zone)
|
||||||
|
{
|
||||||
|
case QiniuConfiguration.UploadZone.CN_East:
|
||||||
|
config.Zone = Zone.ZONE_CN_East;
|
||||||
|
break;
|
||||||
|
case QiniuConfiguration.UploadZone.CN_North:
|
||||||
|
config.Zone = Zone.ZONE_CN_North;
|
||||||
|
break;
|
||||||
|
case QiniuConfiguration.UploadZone.CN_South:
|
||||||
|
config.Zone = Zone.ZONE_CN_South;
|
||||||
|
break;
|
||||||
|
case QiniuConfiguration.UploadZone.US_North:
|
||||||
|
config.Zone = Zone.ZONE_US_North;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 设置 http 或者 https 上传
|
||||||
|
config.UseHttps = true;
|
||||||
|
config.UseCdnDomains = true;
|
||||||
|
config.ChunkSize = ChunkUnit.U512K;
|
||||||
|
|
||||||
|
ResumableUploader target = new ResumableUploader(config);
|
||||||
|
HttpResult result = target.UploadStream(filestream, fileName, token,null);
|
||||||
|
|
||||||
if (result.Code != (int)HttpCode.OK)
|
if (result.Code != (int)HttpCode.OK)
|
||||||
{
|
{
|
||||||
File.Delete(fullPath);
|
|
||||||
Log.Error(result.Text);
|
Log.Error(result.Text);
|
||||||
throw new Exception(result.Text);
|
throw new Exception(result.Text);
|
||||||
}
|
}
|
||||||
File.Delete(fullPath);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
GreenshotQiniuPlugin/packages.config
Normal file
5
GreenshotQiniuPlugin/packages.config
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
|
||||||
|
<package id="Qiniu" version="7.3.0" targetFramework="net452" />
|
||||||
|
</packages>
|
Loading…
Add table
Add a link
Reference in a new issue