how to send a pdf file through http-post -
i need send pdf file through http post.
i'm sending using third party (nsoftware) dll.
but question is, how receive @ server end , save it.
i tried httplistener, unable do.
can 1 me on this..
thanks, maddy
i tried below..
public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { listener = new httplistener(); listener.prefixes.add("http://localhost:122/"); listener.authenticationschemes = authenticationschemes.anonymous; listener.start(); this.listenthread1 = new thread(new parameterizedthreadstart(startlistener)); listenthread1.start(); } private void startlistener(object s) { while (true) { processrequest(); } } private void processrequest() { var result = listener.begingetcontext(listenercallback, listener); result.asyncwaithandle.waitone(); } private void listenercallback(iasyncresult result) { var context = listener.endgetcontext(result); thread.sleep(1000); var data_text = new streamreader(context.request.inputstream, context.request.contentencoding).readtoend(); var cleaned_data = system.web.httputility.urldecode(data_text); byte[] bytes = new byte[1024 * 1024]; int size = 1024 * 1024; context.request.inputstream.read(bytes, 0, size); using (filestream fsnew = new filestream("e:\\temp\\test.pdf", filemode.create, fileaccess.write)) { fsnew.write(bytes, 0, bytes.length); } context.response.statuscode = 200; context.response.statusdescription = "ok"; messagebox.show(cleaned_data); context.response.close(); }
with i'm able save create pdf it's not opening, , data more actual in original pdf (i think headers of http).
i hope makes sense...
thanks, madhu
Comments
Post a Comment