|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
@ -16,36 +17,43 @@ namespace S3Demo.Helper
|
|
|
|
|
{
|
|
|
|
|
string result = "";
|
|
|
|
|
|
|
|
|
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
|
|
|
|
|
|
|
|
|
req.Method = "POST";
|
|
|
|
|
req.Method = "POST";
|
|
|
|
|
|
|
|
|
|
req.Timeout = 10000;
|
|
|
|
|
req.Timeout = 10000;
|
|
|
|
|
|
|
|
|
|
req.ContentType = "application/json";
|
|
|
|
|
req.ContentType = "application/json";
|
|
|
|
|
|
|
|
|
|
byte[] data = Encoding.UTF8.GetBytes(postData);
|
|
|
|
|
byte[] data = Encoding.UTF8.GetBytes(postData);
|
|
|
|
|
|
|
|
|
|
req.ContentLength = data.Length;
|
|
|
|
|
req.ContentLength = data.Length;
|
|
|
|
|
|
|
|
|
|
using (Stream reqStream = req.GetRequestStream())
|
|
|
|
|
{
|
|
|
|
|
reqStream.Write(data, 0, data.Length);
|
|
|
|
|
using (Stream reqStream = req.GetRequestStream())
|
|
|
|
|
{
|
|
|
|
|
reqStream.Write(data, 0, data.Length);
|
|
|
|
|
|
|
|
|
|
reqStream.Close();
|
|
|
|
|
}
|
|
|
|
|
reqStream.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
|
|
|
|
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
|
|
|
|
|
|
|
|
|
Stream stream = resp.GetResponseStream();
|
|
|
|
|
Stream stream = resp.GetResponseStream();
|
|
|
|
|
|
|
|
|
|
//获取响应内容
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
|
|
|
|
//获取响应内容
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
|
|
|
|
{
|
|
|
|
|
result = reader.ReadToEnd();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
result = reader.ReadToEnd();
|
|
|
|
|
return ex.Message.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|