WCF Restful服务文件上传,支持多平台

任何人都可以请告诉我如何创建一个WCF Rest服务,通过它我可以使用android,iphone和WP7将文件上传到服务器。

感谢您的帮助,我能够为多个平台创建文件上传wcfrest服务。

public void FileUpload(string fileName, Stream fileStream) { FileStream fileToupload = new FileStream("c:\\FileUpload\\" + fileName, FileMode.Create); byte[] bytearray = new byte[10000]; int bytesRead, totalBytesRead = 0; do { bytesRead = fileStream.Read(bytearray, 0, bytearray.Length); totalBytesRead += bytesRead; } while (bytesRead > 0); fileToupload.Write(bytearray, 0, bytearray.Length); fileToupload.Close(); fileToupload.Dispose(); } [ServiceContract] public interface IImageUpload { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = "FileUpload/{fileName}")] void FileUpload(string fileName, Stream fileStream); } 

可以使用Android,iphone和WP7访问任何Rest service

一种选择是使用WCFMVC创建Rest POST服务,并将data的图像作为base64字符串。