|
@@ -72,6 +72,7 @@ namespace MBIRevitBase.Tools
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public static BResult PostFormDataFileThrowException(string url, Stream stream)
|
|
public static BResult PostFormDataFileThrowException(string url, Stream stream)
|
|
{
|
|
{
|
|
|
|
+ BResult rslt= (BResult)string.Empty;
|
|
using (HttpClient client = CreateClient())
|
|
using (HttpClient client = CreateClient())
|
|
{
|
|
{
|
|
try
|
|
try
|
|
@@ -80,10 +81,13 @@ namespace MBIRevitBase.Tools
|
|
client.Timeout = new TimeSpan(0, 30, 0);
|
|
client.Timeout = new TimeSpan(0, 30, 0);
|
|
string boundary = string.Format("{0}{1}", WebKitFormBoundary, DateTime.Now.Ticks.ToString("x"));
|
|
string boundary = string.Format("{0}{1}", WebKitFormBoundary, DateTime.Now.Ticks.ToString("x"));
|
|
MultipartFormDataContent content = new MultipartFormDataContent(boundary);
|
|
MultipartFormDataContent content = new MultipartFormDataContent(boundary);
|
|
|
|
+
|
|
#region Stream请求
|
|
#region Stream请求
|
|
|
|
+
|
|
var streamContent = new StreamContent(stream);
|
|
var streamContent = new StreamContent(stream);
|
|
//"file.zip"必须有,它的格式可能影响到内部的一些配置
|
|
//"file.zip"必须有,它的格式可能影响到内部的一些配置
|
|
content.Add(streamContent, "file", "file.zip");
|
|
content.Add(streamContent, "file", "file.zip");
|
|
|
|
+
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
var tt = client.PostAsync(url, content);
|
|
var tt = client.PostAsync(url, content);
|
|
@@ -91,20 +95,24 @@ namespace MBIRevitBase.Tools
|
|
|
|
|
|
if (result.IsSuccessStatusCode)
|
|
if (result.IsSuccessStatusCode)
|
|
{
|
|
{
|
|
- string rslt = result.Content.ReadAsStringAsync().Result;
|
|
|
|
- return ((HttpResult)rslt);
|
|
|
|
|
|
+ rslt = (HttpResult) result.Content.ReadAsStringAsync().Result;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
throw new Exception(result.ToString());
|
|
throw new Exception(result.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ throw new Exception(e.ToString());
|
|
|
|
+ }
|
|
finally
|
|
finally
|
|
{
|
|
{
|
|
client.Dispose();
|
|
client.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return string.Empty;
|
|
|
|
|
|
+
|
|
|
|
+ return rslt;
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|