Merge pull request #2569 from maxibanki/master

Plik FileUploader changes
This commit is contained in:
Jaex 2017-06-10 22:50:58 +03:00 committed by GitHub
commit 9db233c43c
5 changed files with 57 additions and 24 deletions

View file

@ -82,8 +82,14 @@ public override UploadResult Upload(Stream stream, string fileName)
metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length); metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length);
metaDataReq.Removable = Settings.Removable; metaDataReq.Removable = Settings.Removable;
metaDataReq.OneShot = Settings.OneShot; metaDataReq.OneShot = Settings.OneShot;
metaDataReq.Ttl = Convert.ToInt32(GetMultiplyIndex(2, Settings.TTLUnit) * Settings.TTL * 60); if (Settings.TTLUnit != 3) // everything except the expire time -1
{
metaDataReq.Ttl = Convert.ToInt32(GetMultiplyIndex(2, Settings.TTLUnit) * Settings.TTL * 60);
}
else
{
metaDataReq.Ttl = -1;
}
if (Settings.HasComment) if (Settings.HasComment)
{ {
metaDataReq.Comment = Settings.Comment; metaDataReq.Comment = Settings.Comment;
@ -111,6 +117,24 @@ private UploadResult ConvertResult(UploadMetadataResponse metaData, UploadResult
return result; return result;
} }
internal static void CalculateTTLValue(NumericUpDown ttlElement, int newUnit, int oldUnit)
{
if (newUnit != 3)
{
if (ttlElement.Value == -1)
{
ttlElement.Value = 1;
}
ttlElement.Value = ttlElement.Value * GetMultiplyIndex(newUnit, oldUnit);
ttlElement.ReadOnly = false;
}
else
{
ttlElement.Value = -1;
ttlElement.ReadOnly = true;
}
}
internal static decimal GetMultiplyIndex(int newUnit, int oldUnit) internal static decimal GetMultiplyIndex(int newUnit, int oldUnit)
{ {
decimal multiplyValue = 1m; decimal multiplyValue = 1m;

View file

@ -34,7 +34,7 @@ public class PlikSettings
public string Password = ""; public string Password = "";
public bool Removable = false; public bool Removable = false;
public bool OneShot = false; public bool OneShot = false;
public int TTLUnit = 0; public int TTLUnit = 2;
public decimal TTL = 30; public decimal TTL = 30;
public bool HasComment = false; public bool HasComment = false;
public string Comment = ""; public string Comment = "";

View file

@ -289,6 +289,8 @@ private void InitializeComponent()
this.lblAmazonS3AccessKey = new System.Windows.Forms.Label(); this.lblAmazonS3AccessKey = new System.Windows.Forms.Label();
this.txtAmazonS3AccessKey = new System.Windows.Forms.TextBox(); this.txtAmazonS3AccessKey = new System.Windows.Forms.TextBox();
this.tpAzureStorage = new System.Windows.Forms.TabPage(); this.tpAzureStorage = new System.Windows.Forms.TabPage();
this.cbAzureStorageEnvironment = new System.Windows.Forms.ComboBox();
this.lblAzureStorageEnvironment = new System.Windows.Forms.Label();
this.btnAzureStoragePortal = new System.Windows.Forms.Button(); this.btnAzureStoragePortal = new System.Windows.Forms.Button();
this.txtAzureStorageContainer = new System.Windows.Forms.TextBox(); this.txtAzureStorageContainer = new System.Windows.Forms.TextBox();
this.lblAzureStorageContainer = new System.Windows.Forms.Label(); this.lblAzureStorageContainer = new System.Windows.Forms.Label();
@ -648,8 +650,6 @@ private void InitializeComponent()
this.lblWidthHint = new System.Windows.Forms.Label(); this.lblWidthHint = new System.Windows.Forms.Label();
this.ttlvMain = new ShareX.HelpersLib.TabToListView(); this.ttlvMain = new ShareX.HelpersLib.TabToListView();
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl(); this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
this.lblAzureStorageEnvironment = new System.Windows.Forms.Label();
this.cbAzureStorageEnvironment = new System.Windows.Forms.ComboBox();
this.tpOtherUploaders.SuspendLayout(); this.tpOtherUploaders.SuspendLayout();
this.tcOtherUploaders.SuspendLayout(); this.tcOtherUploaders.SuspendLayout();
this.tpTwitter.SuspendLayout(); this.tpTwitter.SuspendLayout();
@ -2698,6 +2698,23 @@ private void InitializeComponent()
this.tpAzureStorage.Name = "tpAzureStorage"; this.tpAzureStorage.Name = "tpAzureStorage";
this.tpAzureStorage.UseVisualStyleBackColor = true; this.tpAzureStorage.UseVisualStyleBackColor = true;
// //
// cbAzureStorageEnvironment
//
this.cbAzureStorageEnvironment.FormattingEnabled = true;
this.cbAzureStorageEnvironment.Items.AddRange(new object[] {
resources.GetString("cbAzureStorageEnvironment.Items"),
resources.GetString("cbAzureStorageEnvironment.Items1"),
resources.GetString("cbAzureStorageEnvironment.Items2"),
resources.GetString("cbAzureStorageEnvironment.Items3")});
resources.ApplyResources(this.cbAzureStorageEnvironment, "cbAzureStorageEnvironment");
this.cbAzureStorageEnvironment.Name = "cbAzureStorageEnvironment";
this.cbAzureStorageEnvironment.SelectedIndexChanged += new System.EventHandler(this.cbAzureStorageEnvironment_SelectedIndexChanged);
//
// lblAzureStorageEnvironment
//
resources.ApplyResources(this.lblAzureStorageEnvironment, "lblAzureStorageEnvironment");
this.lblAzureStorageEnvironment.Name = "lblAzureStorageEnvironment";
//
// btnAzureStoragePortal // btnAzureStoragePortal
// //
resources.ApplyResources(this.btnAzureStoragePortal, "btnAzureStoragePortal"); resources.ApplyResources(this.btnAzureStoragePortal, "btnAzureStoragePortal");
@ -4001,6 +4018,11 @@ private void InitializeComponent()
1808227885, 1808227885,
5, 5,
0}); 0});
this.nudPlikTTL.Minimum = new decimal(new int[] {
1,
0,
0,
-2147483648});
this.nudPlikTTL.Name = "nudPlikTTL"; this.nudPlikTTL.Name = "nudPlikTTL";
this.nudPlikTTL.Value = new decimal(new int[] { this.nudPlikTTL.Value = new decimal(new int[] {
1, 1,
@ -4016,7 +4038,8 @@ private void InitializeComponent()
this.cbxPlikTTLUnit.Items.AddRange(new object[] { this.cbxPlikTTLUnit.Items.AddRange(new object[] {
resources.GetString("cbxPlikTTLUnit.Items"), resources.GetString("cbxPlikTTLUnit.Items"),
resources.GetString("cbxPlikTTLUnit.Items1"), resources.GetString("cbxPlikTTLUnit.Items1"),
resources.GetString("cbxPlikTTLUnit.Items2")}); resources.GetString("cbxPlikTTLUnit.Items2"),
resources.GetString("cbxPlikTTLUnit.Items3")});
resources.ApplyResources(this.cbxPlikTTLUnit, "cbxPlikTTLUnit"); resources.ApplyResources(this.cbxPlikTTLUnit, "cbxPlikTTLUnit");
this.cbxPlikTTLUnit.Name = "cbxPlikTTLUnit"; this.cbxPlikTTLUnit.Name = "cbxPlikTTLUnit";
this.cbxPlikTTLUnit.SelectedIndexChanged += new System.EventHandler(this.cbxPlikTTLUnit_SelectedIndexChanged); this.cbxPlikTTLUnit.SelectedIndexChanged += new System.EventHandler(this.cbxPlikTTLUnit_SelectedIndexChanged);
@ -5266,23 +5289,6 @@ private void InitializeComponent()
this.actRapidShareAccountType.Name = "actRapidShareAccountType"; this.actRapidShareAccountType.Name = "actRapidShareAccountType";
this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous; this.actRapidShareAccountType.SelectedAccountType = ShareX.UploadersLib.AccountType.Anonymous;
// //
// lblAzureStorageEnvironment
//
resources.ApplyResources(this.lblAzureStorageEnvironment, "lblAzureStorageEnvironment");
this.lblAzureStorageEnvironment.Name = "lblAzureStorageEnvironment";
//
// cbAzureStorageEnvironment
//
this.cbAzureStorageEnvironment.FormattingEnabled = true;
this.cbAzureStorageEnvironment.Items.AddRange(new object[] {
resources.GetString("cbAzureStorageEnvironment.Items"),
resources.GetString("cbAzureStorageEnvironment.Items1"),
resources.GetString("cbAzureStorageEnvironment.Items2"),
resources.GetString("cbAzureStorageEnvironment.Items3")});
resources.ApplyResources(this.cbAzureStorageEnvironment, "cbAzureStorageEnvironment");
this.cbAzureStorageEnvironment.Name = "cbAzureStorageEnvironment";
this.cbAzureStorageEnvironment.SelectedIndexChanged += new System.EventHandler(this.cbAzureStorageEnvironment_SelectedIndexChanged);
//
// UploadersConfigForm // UploadersConfigForm
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");

View file

@ -2972,7 +2972,7 @@ private void cbPlikOneShot_CheckedChanged(object sender, EventArgs e)
private void cbxPlikTTLUnit_SelectedIndexChanged(object sender, EventArgs e) private void cbxPlikTTLUnit_SelectedIndexChanged(object sender, EventArgs e)
{ {
nudPlikTTL.Value = nudPlikTTL.Value * Plik.GetMultiplyIndex(cbxPlikTTLUnit.SelectedIndex, Config.PlikSettings.TTLUnit); ; Plik.CalculateTTLValue(nudPlikTTL, cbxPlikTTLUnit.SelectedIndex, Config.PlikSettings.TTLUnit);
Config.PlikSettings.TTLUnit = cbxPlikTTLUnit.SelectedIndex; Config.PlikSettings.TTLUnit = cbxPlikTTLUnit.SelectedIndex;
} }

View file

@ -11497,6 +11497,9 @@ Using an encrypted library disables sharing.</value>
<data name="cbxPlikTTLUnit.Items2" xml:space="preserve"> <data name="cbxPlikTTLUnit.Items2" xml:space="preserve">
<value>minutes</value> <value>minutes</value>
</data> </data>
<data name="cbxPlikTTLUnit.Items3" xml:space="preserve">
<value>never</value>
</data>
<data name="cbxPlikTTLUnit.Location" type="System.Drawing.Point, System.Drawing"> <data name="cbxPlikTTLUnit.Location" type="System.Drawing.Point, System.Drawing">
<value>117, 217</value> <value>117, 217</value>
</data> </data>