c# - Passing parameters using request headers when using Stream -
in wcf service there method uploading image files:
uploadimage(stream imagedata);
edit - answers suggest, next line wrong, , it's possible!
as stream being used, no other parameters allowed method, needed.
i understand there open source projects can handle multi-part stream in can pass more params, thinking request headers might simpler solution.
so i'm wondering might downside of using "request headers" approach in case?
thanks!
as stream being used, no other parameters allowed method, needed.
not really. should work.
[operationcontract,webinvoke(uritemplate="{name}")] uploadimage(stream imagedata, string name);
here working sample
async void testmethod() { task.run(() => { var host = new webservicehost(typeof(mycontract), new uri("http://0.0.0.0:8088/test")); host.open(); }); await task.delay(2000); new webclient().uploaddata("http://localhost:8088/test/uploadimage/abc.bmp", new byte[] { 65, 66, 67, 68, 69 }); } [servicecontract] class mycontract { [operationcontract, webinvoke(uritemplate = "/uploadimage/{name}")] public void uploadimage(stream s, string name) { console.writeline(name + " -> " + new streamreader(s).readtoend()); } }
Comments
Post a Comment