using System; using System.Collections.Generic; using System.IO; using System.Net.Http; using System.Threading.Tasks; namespace nuget_cli { internal class PushCommand { static internal async Task RunAsync(string pkg, string source, string apikey) { var report = new PushReport { PkgName = pkg }; FileInfo fi = new FileInfo(pkg); if (!fi.Exists) throw new Exception("Le fichier n'existe pas"); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("api-key", apikey); client.BaseAddress = new Uri(source); var content = new StreamContent(fi.OpenRead()); var response = await client.PutAsync(source, content); report.StatusCode = response.StatusCode.ToString(); report.Message = await response.Content.ReadAsStringAsync(); report.Executed = true; return report; } } }