From e9935b16a915631bed895698be48db4a489837cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=9C=B2=E5=B0=A7?= Date: Mon, 13 Mar 2023 12:36:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3=20=E4=BC=A0=E8=BE=93=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=BA=20multipart/form-data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HttpWebService.cs | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/93_nei_core/Getf_Service_Transfer_Client_Service_HttpHandler/HttpWebService.cs b/93_nei_core/Getf_Service_Transfer_Client_Service_HttpHandler/HttpWebService.cs index ed38dcf..c6af492 100644 --- a/93_nei_core/Getf_Service_Transfer_Client_Service_HttpHandler/HttpWebService.cs +++ b/93_nei_core/Getf_Service_Transfer_Client_Service_HttpHandler/HttpWebService.cs @@ -56,18 +56,36 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler var bodyParam = jObject["Param"]; if (data != null && data.Length > 0) { - httpRequst.SetRequestUrl(url + "byte"); - BodyEntity be = new(); + //httpRequst.SetRequestUrl(url + "byte"); + //BodyEntity be = new(); + //if (bodyData != null) + //{ + // if (bodyData["commond"] != null) + // be.commond = bodyData["commond"].ToString(); + // if (bodyData["fileName"] != null) + // be.FileName = bodyData["fileName"].ToString(); + // be.bytes = data; + //} + //httpRequst.SetBody(be); + ////_LogHelper.Info($"body:{Newtonsoft.Json.JsonConvert.SerializeObject(be)}"); + httpRequst.SetContentType("multipart/form-data"); if (bodyData != null) { + httpRequst.SetFiles(HttpFile.Create("file", data, "image.png")); if (bodyData["commond"] != null) - be.commond = bodyData["commond"].ToString(); - if (bodyData["fileName"] != null) - be.FileName = bodyData["fileName"].ToString(); - be.bytes = data; + { + var dic = new Dictionary(); + var childs = bodyData["commond"].Children(); + foreach (var child in childs) + { + var name = ((Newtonsoft.Json.Linq.JProperty)child).Name; + var value = ((Newtonsoft.Json.Linq.JProperty)child).Value.ToString(); + dic.Add(name, value); + } + //httpRequst.SetBody(Newtonsoft.Json.JsonConvert.DeserializeObject(bodyData["commond"].ToString()), "multipart/form-data"); + httpRequst.SetBody(dic, "multipart/form-data"); + } } - httpRequst.SetBody(be); - _LogHelper.Info($"body:{Newtonsoft.Json.JsonConvert.SerializeObject(be)}"); } else {