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