internal async Task <ExecuteResult> Upload(ExecuteParams param, UploadParams uploadParam) { param.Method = Methods.Post; var byteContent = uploadParam.GetFileBytes(); HttpContent content = new ByteArrayContent(byteContent); //content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data"); content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { FileName = $"{uploadParam.FileName}", Name = "file" }; using (var form = new MultipartFormDataContent()) { form.Add(content); using (var client = new HttpClient()) { SetHeaders(client, param); var response = await client.PostAsync(GetUrl(param), form); bool success = await LogPossibleError(param, response); return(await GetResponseResult(param, response, success)); } } }
internal async Task <T> Upload <T>(ExecuteParams param, UploadParams uploadParam) => (await Upload(param, uploadParam)).ConvertToData <T>();