public void UploadMultiFilesTest()
{
var message = new HttpRequestMessage();
var content = new MultipartFormDataContent();
string[] fileUploadPaths = { @"C:\Users\Acer\Pictures\photo_2020-12-16_10-25-16.jpg" };
int count = 0;
foreach (string fileUploadPath in fileUploadPaths)
{
var filestream = new FileStream(fileUploadPath, FileMode.Open);
var fileName = Path.GetFileName(fileUploadPath);
content.Add(new StreamContent(filestream), "file_" + (++count), fileName);
}
content.Add(new StringContent("this is value"), "json_key");
var client = new HttpClient();
client.PostAsync("http://localhost:6764/MediaUpload", content).ContinueWith(task =>
{
if (task.Result.IsSuccessStatusCode)
{
//
}
});
}
Không có nhận xét nào:
Đăng nhận xét