var fileStream = new MemoryStream(fileContent); var parametersList = new MultipartFormDataContent { { new StringContent(folderName), "FolderName" }, { new StringContent(fileName), "FileName" }, { new StreamContent(fileStream), "FileContent" } }; var responseJson = this.DoPostQuery(parametersList, AppConfig.GetEcmWholesaleUploadFileUrl()).Result; public async Task<string> DoPostQuery(MultipartFormDataContent multiForm, string url) { /* MultipartFormDataContent=》multipart/form-data FormUrlEncodedContent=》application/x-www-form-urlencoded StringContent=》application/json等 StreamContent=》binary */ var httpClient = new HttpClient(); var response = await httpClient.PostAsync(url, multiForm); string responseJson = await response.Content.ReadAsStringAsync(); return responseJson; }
标签:responseJson,StringContent,MultipartFormDataContent,var,new,HttpClient From: https://www.cnblogs.com/hofmann/p/17714044.html