C# android-web api发送/接收图像
我相信这是一个常见的问题,我可能会找到解决办法,但我不理解。此外,我做这件事完全是盲目的。另一点是:我不想使用第三方库 我需要通过c#rest Web服务将安卓应用程序中的图像发送到服务器 我观察了将位图转换为字节[]的方法C# android-web api发送/接收图像,c#,android,json,rest,asp.net-web-api,C#,Android,Json,Rest,Asp.net Web Api,我相信这是一个常见的问题,我可能会找到解决办法,但我不理解。此外,我做这件事完全是盲目的。另一点是:我不想使用第三方库 我需要通过c#rest Web服务将安卓应用程序中的图像发送到服务器 我观察了将位图转换为字节[]的方法 public static byte[] getBitmapAsByteArray(Bitmap bitmap) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
public static byte[] getBitmapAsByteArray(Bitmap bitmap) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.JPEG, 0, outputStream);
return outputStream.toByteArray();
}
这里我有两个(至少)问题:
感谢并抱歉提出这个可怕的问题Android:
byte[] content = getBitmapAsByteArray(bitmap);
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new ByteArrayEntity(content));
HttpResponse response = httpClient.execute(httpPost);
c#net
byte[] fileData = null;
using (var binaryReader = new BinaryReader(Request.Files[0].InputStream))
{
fileData = binaryReader.ReadBytes(Request.Files[0].ContentLength);
}
首先,谢谢你的回答。第二,Android部分,它已经被弃用了。