如何使用 发布字节数组图片HttpWebRequest
?
img 是一个字节数组。
下面是代码,当我使用 parse 函数时,我无法将 byte[] img 转换为 string :
// Parse is the function to replace @xxx with a new string
string docString = Parse("action=@action&img=@img&signloclat=@lat&lng=@lng&id=@id",
"@action", "upload", "@img", img, "@lat", latitude, "@lng", longitude, "@id", id);
byte[] docByte = Encoding.ASCII.GetBytes(docString);
Uri wsHost = new Uri(EnpointAddress());
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(wsHost);
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.ContentLength = docByte.Length;
Stream stream = request.GetRequestStream();
stream.Write(docByte, 0, docByte.Length);
stream.Close();
如何使用字符串发布字节数组HttpWebRequest
?
我可以在发送之前将字节数组转换为字符串吗?
谢谢你。