Update nuget + imbastito file upload, NON VA (errore server?)
This commit is contained in:
@@ -1516,7 +1516,7 @@ namespace MConnectSDK
|
||||
// return finale dello status della chiamata...
|
||||
return _currReq;
|
||||
}
|
||||
public async Task<Result> TryUpLoadFile(CancellationToken token, IProgress<Result> progress, string pathFile)
|
||||
public async Task<Result> TryUpLoadFile(CancellationToken token, IProgress<Result> progress, string fileName)
|
||||
{
|
||||
Result result = new Result();
|
||||
|
||||
@@ -1525,8 +1525,10 @@ namespace MConnectSDK
|
||||
result.Payload = new FileUpLoadPayload();
|
||||
result.CallResultOk = true;
|
||||
|
||||
// trasformo filepath --> nome + bytestream...
|
||||
var uplResult = Utils.uploadAsync(pageUrlFileUpload, "nomeFile", new byte[]);
|
||||
byte[] fileBytes = File.ReadAllBytes(fileName);
|
||||
|
||||
// trasformo filepath --> nome + bytestream...
|
||||
var uplResult = Utils.uploadAsync(pageUrlFileUpload, fileName, fileBytes);
|
||||
|
||||
|
||||
|
||||
@@ -1541,7 +1543,7 @@ namespace MConnectSDK
|
||||
result.Payload = new FileUpLoadPayload()
|
||||
{
|
||||
expiry = DateTime.Now.AddHours(1).ToString("o"),
|
||||
filename = Path.GetFileNameWithoutExtension(pathFile),
|
||||
filename = Path.GetFileNameWithoutExtension(fileName),
|
||||
link = $"http:\\"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.6.0\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.1.1.14\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.0.11\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\StackExchange.Redis.2.0.519\lib\net461\StackExchange.Redis.dll</HintPath>
|
||||
<HintPath>..\packages\StackExchange.Redis.2.0.571\lib\net461\StackExchange.Redis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
@@ -82,8 +82,8 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\YamlDotNet.5.4.0\lib\net45\YamlDotNet.dll</HintPath>
|
||||
<Reference Include="YamlDotNet, Version=6.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\YamlDotNet.6.0.0\lib\net45\YamlDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -167,10 +167,11 @@ namespace MConnectSDK
|
||||
/// <summary>
|
||||
/// Caricamento file come multipart in modalità async
|
||||
/// </summary>
|
||||
/// <param name="pageUrl"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="fileContent"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<string> uploadAsync(string pageUrl = "https://stg.api.maestroconnect.scmgroup.com/storage-api/backups", string fileName, byte[] fileContent)
|
||||
public static async Task<string> uploadAsync(string pageUrl, string fileName, byte[] fileContent)
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
|
||||
<package id="NLog" version="4.5.11" targetFramework="net462" />
|
||||
<package id="Pipelines.Sockets.Unofficial" version="1.1.14" targetFramework="net462" />
|
||||
<package id="StackExchange.Redis" version="2.0.519" targetFramework="net462" />
|
||||
<package id="NLog" version="4.6.0" targetFramework="net462" />
|
||||
<package id="Pipelines.Sockets.Unofficial" version="2.0.11" targetFramework="net462" />
|
||||
<package id="StackExchange.Redis" version="2.0.571" targetFramework="net462" />
|
||||
<package id="System.Buffers" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.Diagnostics.PerformanceCounter" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.IO.Pipelines" version="4.5.3" targetFramework="net462" />
|
||||
@@ -12,5 +12,5 @@
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net462" />
|
||||
<package id="System.Threading.Channels" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net462" />
|
||||
<package id="YamlDotNet" version="5.4.0" targetFramework="net462" />
|
||||
<package id="YamlDotNet" version="6.0.0" targetFramework="net462" />
|
||||
</packages>
|
||||
Generated
+14
-1
@@ -63,6 +63,7 @@
|
||||
this.pictBox = new System.Windows.Forms.PictureBox();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.lblConsole = new System.Windows.Forms.Label();
|
||||
this.btnUploadFile = new System.Windows.Forms.Button();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
@@ -106,12 +107,13 @@
|
||||
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.groupBox1.AutoSize = true;
|
||||
this.groupBox1.Controls.Add(this.btnUploadFile);
|
||||
this.groupBox1.Controls.Add(this.lblUserCode);
|
||||
this.groupBox1.Controls.Add(this.txtConfFile);
|
||||
this.groupBox1.Controls.Add(this.label3);
|
||||
this.groupBox1.Location = new System.Drawing.Point(13, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(1063, 74);
|
||||
this.groupBox1.Size = new System.Drawing.Size(1063, 78);
|
||||
this.groupBox1.TabIndex = 11;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Connection Parameters";
|
||||
@@ -435,6 +437,16 @@
|
||||
this.lblConsole.TabIndex = 7;
|
||||
this.lblConsole.Text = "...";
|
||||
//
|
||||
// btnUploadFile
|
||||
//
|
||||
this.btnUploadFile.Location = new System.Drawing.Point(426, 25);
|
||||
this.btnUploadFile.Name = "btnUploadFile";
|
||||
this.btnUploadFile.Size = new System.Drawing.Size(111, 32);
|
||||
this.btnUploadFile.TabIndex = 31;
|
||||
this.btnUploadFile.Text = "<-- Upload test";
|
||||
this.btnUploadFile.UseVisualStyleBackColor = true;
|
||||
this.btnUploadFile.Click += new System.EventHandler(this.btnUploadFile_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
@@ -496,6 +508,7 @@
|
||||
private System.Windows.Forms.Button btnDeleteUserCloud;
|
||||
private System.Windows.Forms.Label lblUserCode;
|
||||
private System.Windows.Forms.Button btnTryEnroll;
|
||||
private System.Windows.Forms.Button btnUploadFile;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -807,5 +807,38 @@ namespace TestClient
|
||||
MessageBox.Show("COPIED current user_code to Clipboard!\r\n" + lblUserCode.Text, "USER_CODE ACQUIRED", MessageBoxButtons.OK);
|
||||
}
|
||||
|
||||
private async void btnUploadFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
// elimino eventuali cancel presenti...
|
||||
if (_cts.IsCancellationRequested)
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
}
|
||||
CancellationToken token = _cts.Token;
|
||||
// gestione progress...
|
||||
var progressHandler = new Progress<Result>(value =>
|
||||
{
|
||||
// aggiorno richeista live...
|
||||
reqStatus = value;
|
||||
refreshRequestStatus();
|
||||
// mostro i dati SPECIFICI x AUTH...
|
||||
updateAuthData((ActivationPayload)value.Payload);
|
||||
});
|
||||
var progress = progressHandler as IProgress<Result>;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var taskResult = MCC.TryUpLoadFile(token, progress, txtConfFile.Text.Trim());
|
||||
#if false
|
||||
// salvo il risultato restituito...
|
||||
reqStatus = taskResult.Result;
|
||||
|
||||
synchronizationContext.Post(new SendOrPostCallback(o =>
|
||||
{
|
||||
refreshRequestStatus();
|
||||
}), "");
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.5.11\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.6.0\lib\net45\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.Windows.Forms.4.2.3\lib\net35\NLog.Windows.Forms.dll</HintPath>
|
||||
@@ -146,6 +146,7 @@
|
||||
<Content Include="resources\userImg.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="testing\Appunti.txt" />
|
||||
</ItemGroup>
|
||||
<Target Name="MyTask" AfterTargets="Build">
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
|
||||
<package id="NLog" version="4.5.11" targetFramework="net462" />
|
||||
<package id="NLog" version="4.6.0" targetFramework="net462" />
|
||||
<package id="NLog.Windows.Forms" version="4.2.3" targetFramework="net462" />
|
||||
<package id="PrettyBin" version="1.1.0" targetFramework="net462" />
|
||||
<package id="Zen.Barcode.Rendering.Framework" version="3.1.10729.1" targetFramework="net462" />
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
Chiamata upload --> da errore:
|
||||
|
||||
{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
|
||||
{
|
||||
x-ratelimit-limit: 5
|
||||
x-ratelimit-remaining: 4
|
||||
access-control-allow-origin: *
|
||||
access-control-allow-headers: Cache-Control,X-reqed-With,x-requested-with
|
||||
content-security-policy: default-src 'self'
|
||||
x-content-type-options: nosniff
|
||||
Alt-Svc: clear
|
||||
Date: Fri, 29 Mar 2019 20:48:07 GMT
|
||||
Via: 1.1 google
|
||||
X-Powered-By: Express
|
||||
Content-Length: 1148
|
||||
Content-Type: text/html; charset=utf-8
|
||||
}}
|
||||
Reference in New Issue
Block a user