将图像作为流发送(Android)

时间:2013-04-09 22:46:31

标签: c# android rest

我设置了一个REST服务来接收数据流,将其保存为图像。

[OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "UpImage/{path}")]
    void UpImage(string path, Stream filecontents);

public void UpImage(string path, Stream filecontents)
    {
        Image img = System.Drawing.Image.FromStream(filecontents);
        img.Save(System.Web.Hosting.HostingEnvironment.MapPath("~/attachments/test/") + "SrvTest.jpg", ImageFormat.Jpeg);
    }

我想通过Android上的AsyncTask来连接服务并收集响应。

我的问题是我不知道如何将图像作为流发送,我看到很多信息将它们作为字节数组发送。 这可能吗?如果可以的话怎么样?

0 个答案:

没有答案