This commit is contained in:
Paul Schneider 2021-05-11 23:01:11 +01:00
commit 97dec15153
5 changed files with 75 additions and 78 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
@ -22,19 +23,30 @@ namespace nuget_cli
if (fi.Length > MAXSENDLEN)
throw new Exception($"Le fichier ne passe pas, trop gros ({MAXSENDLEN}).");
var fparams = new Dictionary<string, string> { { "userid", "9" } };
var fparams = new Dictionary<string, string> { };
using (var fss = fi.OpenRead())
{
try
{
byte[] buffer = new byte[MAXSENDLEN];
var form_bytes_read = fss.Read(buffer, 0, MAXSENDLEN);
report.UploadFilesToServer(new Uri(source), fparams, fi.Name, "application/octet-stream",
apikey, buffer);
report.UploadFilesToServer(new Uri(source),
fparams, fi.Name, "application/octet-stream",
apikey, buffer);
}
catch (WebException ex)
{
await Console.Error.WriteLineAsync(ex.Message);
report.StatusCode = ex.Status.ToString();
using (var respStream = ex.Response.GetResponseStream())
{
StreamReader sr = new StreamReader(respStream);
report.Message = sr.ReadToEnd();
}
}
catch (Exception ex)
{
await Console.Error.WriteLineAsync(ex.Message);