0
Answer

Web Service and loading images from/to a Web Site

Bo Wiklund

Bo Wiklund

21y
1.9k
1
I have created an XML Web Service that interacts with Web Site (a Web Shop). I want to upload (and download) images from the Web Site to the Web Service client. The problem is that File.OpenRead("myURI") is not supporting URI as parameter in the server. Otherwise it works OK (with a normal filename). Is there any method to access a file through the browser and stream it like with a normal file access? My code is something like: (It works if "myURI" is a local folder) Client (invoke): byte[] result = new Byte[]{}; result = wsInvoke.sendBytesToClient("myURI"); Stream outputStream = File.OpenWrite("myLocalFolder"); outputStream.Write(result,0,result.Length); outputStream.Close(); Server (response): Stream inputStream = File.OpenRead("myURI"); byte[] byteArray = new byte[inputStream.Length]; inputStream.Read(byteArray,0,(int)inputStream.Length); inputStream.Close(); return byteArray;