修改上传文件接口 传输类型为 multipart/form-data
This commit is contained in:
@@ -56,18 +56,36 @@ namespace Getf_Service_Transfer_Client_Service_HttpHandler
|
|||||||
var bodyParam = jObject["Param"];
|
var bodyParam = jObject["Param"];
|
||||||
if (data != null && data.Length > 0)
|
if (data != null && data.Length > 0)
|
||||||
{
|
{
|
||||||
httpRequst.SetRequestUrl(url + "byte");
|
//httpRequst.SetRequestUrl(url + "byte");
|
||||||
BodyEntity be = new();
|
//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)
|
if (bodyData != null)
|
||||||
{
|
{
|
||||||
|
httpRequst.SetFiles(HttpFile.Create("file", data, "image.png"));
|
||||||
if (bodyData["commond"] != null)
|
if (bodyData["commond"] != null)
|
||||||
be.commond = bodyData["commond"].ToString();
|
{
|
||||||
if (bodyData["fileName"] != null)
|
var dic = new Dictionary<string, object>();
|
||||||
be.FileName = bodyData["fileName"].ToString();
|
var childs = bodyData["commond"].Children();
|
||||||
be.bytes = data;
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user