c# - Upload document to Server using HttpPost -
the application "a" requires upload word-file [as byte array] external application using post.
the filecontent should added named parameter in request body , have make post request upload file.
i have sample code, in java. write equivalent c# code. in c#, not find similar object multipartentity.
java code snippet:
string resturl = hosturl + "/rest/upload/0b002f4780293c18"; string filename = "testrestuploadbyfolderid" + calendar.getinstance().gettimeinmillis() + ".txt"; file testfile = createnewfile("c:/temp/rest/" + filename); filebody content = new filebody(testfile, "application/octet-stream"); system.out.println(" file name : " + content.getfilename() + " ... " + content.gettransferencoding()); multipartentity reqentity = new multipartentity(httpmultipartmode.browser_compatible); reqentity.addpart("filename", new stringbody(filename)); reqentity.addpart("uploadfile", content); httppost httppost = new httppost(resturl); httppost.addheader("accept", "application/json"); httppost.setentity(reqentity); // post request string response = httpclient.execute(httppost, new defaultresponsehandler());
could please post links explains how make named parameter in c# upload filecontent
thank you.
go below link.it may you
or can take java language conversion assistant(jlca) go through link http://support.microsoft.com/kb/819018
Comments
Post a Comment