不确定此代码有什么问题。我得到一个通用的“发送请求时发生错误”。这是C#代码:
string t1 = "/storage/emulated/0/Android/data/com.je.EE/files/Pictures/Observations/";
string t2 = "592018 115019 AM.jpg";
string t3 = "/storage/emulated/0/Android/data/com.je.EE/files/Pictures/Observations/592018 115019 AM.jpg";
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.TransferEncodingChunked = true;
var content = new MultipartFormDataContent();
// var imageContent = new StreamContent(new FileStream("my_path.jpg", FileMode.Open, FileAccess.Read, FileShare.Read));
var imageContent = new StreamContent(new FileStream(t3, FileMode.Open, FileAccess.Read, FileShare.Read));
imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse("image/jpeg");
// content.Add(imageContent, "image", "image.jpg");
content.Add(imageContent, "image", t2);
var url = "http://localhost:62810/api/Files/Upload";
await httpClient.PostAsync(url, content);