mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Plik FileUploader changes
- added the ability to upload files with an infinity expire time - adjusted the default ttl
This commit is contained in:
parent
fbbcf2dfe6
commit
0f30c0e57e
5 changed files with 57 additions and 24 deletions
|
@ -82,8 +82,14 @@ public override UploadResult Upload(Stream stream, string fileName)
|
|||
metaDataReq.Files.File0.FileSize = Convert.ToInt32(stream.Length);
|
||||
metaDataReq.Removable = Settings.Removable;
|
||||
metaDataReq.OneShot = Settings.OneShot;
|
||||
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)
|
||||
{
|
||||
metaDataReq.Comment = Settings.Comment;
|
||||
|
@ -111,6 +117,24 @@ private UploadResult ConvertResult(UploadMetadataResponse metaData, UploadResult
|
|||
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)
|
||||
{
|
||||
decimal multiplyValue = 1m;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class PlikSettings
|
|||
public string Password = "";
|
||||
public bool Removable = false;
|
||||
public bool OneShot = false;
|
||||
public int TTLUnit = 0;
|
||||
public int TTLUnit = 2;
|
||||
public decimal TTL = 30;
|
||||
public bool HasComment = false;
|
||||
public string Comment = "";
|
||||
|
|
|
@ -289,6 +289,8 @@ private void InitializeComponent()
|
|||
this.lblAmazonS3AccessKey = new System.Windows.Forms.Label();
|
||||
this.txtAmazonS3AccessKey = new System.Windows.Forms.TextBox();
|
||||
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.txtAzureStorageContainer = new System.Windows.Forms.TextBox();
|
||||
this.lblAzureStorageContainer = new System.Windows.Forms.Label();
|
||||
|
@ -648,8 +650,6 @@ private void InitializeComponent()
|
|||
this.lblWidthHint = new System.Windows.Forms.Label();
|
||||
this.ttlvMain = new ShareX.HelpersLib.TabToListView();
|
||||
this.actRapidShareAccountType = new ShareX.UploadersLib.AccountTypeControl();
|
||||
this.lblAzureStorageEnvironment = new System.Windows.Forms.Label();
|
||||
this.cbAzureStorageEnvironment = new System.Windows.Forms.ComboBox();
|
||||
this.tpOtherUploaders.SuspendLayout();
|
||||
this.tcOtherUploaders.SuspendLayout();
|
||||
this.tpTwitter.SuspendLayout();
|
||||
|
@ -2698,6 +2698,23 @@ private void InitializeComponent()
|
|||
this.tpAzureStorage.Name = "tpAzureStorage";
|
||||
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
|
||||
//
|
||||
resources.ApplyResources(this.btnAzureStoragePortal, "btnAzureStoragePortal");
|
||||
|
@ -4001,6 +4018,11 @@ private void InitializeComponent()
|
|||
1808227885,
|
||||
5,
|
||||
0});
|
||||
this.nudPlikTTL.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
-2147483648});
|
||||
this.nudPlikTTL.Name = "nudPlikTTL";
|
||||
this.nudPlikTTL.Value = new decimal(new int[] {
|
||||
1,
|
||||
|
@ -4016,7 +4038,8 @@ private void InitializeComponent()
|
|||
this.cbxPlikTTLUnit.Items.AddRange(new object[] {
|
||||
resources.GetString("cbxPlikTTLUnit.Items"),
|
||||
resources.GetString("cbxPlikTTLUnit.Items1"),
|
||||
resources.GetString("cbxPlikTTLUnit.Items2")});
|
||||
resources.GetString("cbxPlikTTLUnit.Items2"),
|
||||
resources.GetString("cbxPlikTTLUnit.Items3")});
|
||||
resources.ApplyResources(this.cbxPlikTTLUnit, "cbxPlikTTLUnit");
|
||||
this.cbxPlikTTLUnit.Name = "cbxPlikTTLUnit";
|
||||
this.cbxPlikTTLUnit.SelectedIndexChanged += new System.EventHandler(this.cbxPlikTTLUnit_SelectedIndexChanged);
|
||||
|
@ -5266,23 +5289,6 @@ private void InitializeComponent()
|
|||
this.actRapidShareAccountType.Name = "actRapidShareAccountType";
|
||||
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
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
|
|
|
@ -2972,7 +2972,7 @@ private void cbPlikOneShot_CheckedChanged(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -11497,6 +11497,9 @@ Using an encrypted library disables sharing.</value>
|
|||
<data name="cbxPlikTTLUnit.Items2" xml:space="preserve">
|
||||
<value>minutes</value>
|
||||
</data>
|
||||
<data name="cbxPlikTTLUnit.Items3" xml:space="preserve">
|
||||
<value>never</value>
|
||||
</data>
|
||||
<data name="cbxPlikTTLUnit.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>117, 217</value>
|
||||
</data>
|
||||
|
|
Loading…
Reference in a new issue