I wish the result to be a success. But what is produced does not enter into the if and else blocks
public async Task<UploadServicesResult> HandleFileUpload(FileInfo file, string path)
{
var fileupload = new StreamContent(new FileStream(file.FullName, FileMode.Open));
multipartContent.Add(fileupload, "file", file.Name);
multipartContent.Add(new StringContent(path), "folder");
multipartContent.Add(new StringContent(s3key), "api_key");
using (HttpResponseMessage response = await httpClient.PostAsync(server, multipartContent))
{
if (response.IsSuccessStatusCode)
{
string responseBody = await response.Content.ReadAsStringAsync();
var messageObj = JsonConvert.DeserializeObject<JObject>(responseBody);
string url = messageObj.Value<string>("url");
return new UploadServicesResult { IsSuccess = true, Message = url };
}
else
{
return new UploadServicesResult { IsSuccess = false, Message = "Upload failed" };
}
}
}