我正在尝试将图片上传到 C#/Xamarin 中的 BaasBox。到目前为止,我只收到错误请求错误:
WebRequest request = WebRequest.Create("http://localhost:9000/file");
request.ContentType = "Content-type: image/jpg";
request.Method = "POST";
string authInfo = "user:password";
request.Headers["Authorization"] = "Basic " + authInfo;
byte[] buffer = new byte[16 * 1024];
using (MemoryStream ms = new MemoryStream())
{
int read;
while ((read = pictureFileStream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
var bytearray = ms.ToArray();
Stream reqstr = await request.GetRequestStreamAsync();
reqstr.Write(bytearray, 0, buffer.Length);
WebResponse response = await request.GetResponseAsync();
Debug.WriteLine("Response: " + response);
}
文档只说它是使用参数文件通过帖子上传的?!