使用WCF Rest服务下载文件?

如果有一种方法使用rest via stream上传文件,还会有“ Download ”吗? 如果是的话,你能告诉我怎么样? 提前致谢!

我用来从我的REST服务下载文件的示例方法:

 [WebGet(UriTemplate = "file/{id}")] public Stream GetPdfFile(string id) { WebOperationContext.Current.OutgoingResponse.ContentType = "application/txt"; FileStream f = new FileStream("C:\\Test.txt", FileMode.Open); int length = (int)f.Length; WebOperationContext.Current.OutgoingResponse.ContentLength = length; byte[] buffer = new byte[length]; int sum = 0; int count; while((count = f.Read(buffer, sum , length - sum)) > 0 ) { sum += count; } f.Close(); return new MemoryStream(buffer); }