Posting File Data Using A Base64 Encoding In ColdFusion -


i trying send xml contains binary file, base64 encoded. when invoke cfhttp, coldfusion 10 server keeps hanging until time-out. visual studio in time debugger keeps popping out.

i using ben nadel's tutorial this post. can ?

  <cffunction name="_push" access="public" returntype="any"> <!---   create path binary file want   post via web service. ---> <cfset strfilepath = expandpath( './myfile.zip' ) />    <!--- read in binary file. ---> <cffile   action="readbinary"   file="#strfilepath#"   variable="objbinarydata"   />   <!---   create xml going post. when posting   file, going encode base64 text data. ---> <!--- <cfsavecontent variable="strxmldata"> ---> <cfxml variable="strxmldata">   <cfoutput>      <file>       <name>#xmlformat(         listlast( strfilepath, "\/" )         )#</name>        <ext>#xmlformat(         listlast( strfilepath, "." )         )#</ext>        <!---         when storing binary data, going         pass file base64 encoding.         95% sure result in valid         xml characters, not sure.       --->       <base64>#binaryencode(objbinarydata,"base64")#</base64>     </file>   </cfoutput> </cfxml> <!--- </cfsavecontent> --->   <!---   build url "web service" going   post file data. ---> <cfset strurl = (   getdirectoryfrompath(     getpagecontext().getrequest().getrequesturl().tostring()     ) &   "webservice.cfm"   ) />   <cftry>    <!--- post xml data "web service" file. --->   <cfhttp     url="#strurl#"     result="httpresponse"     method="post"     throwonerror="yes"     timeout="60">      <!--- post xml data. --->     <cfhttpparam       type="xml"       value="#strxmldata#"       name="myxml"       />    </cfhttp>                    <cfcatch type="any">       <cfdump var="#cfcatch#" output="c:/dump-a.txt">       <cfset httpresponse = cfcatch>    </cfcatch> </cftry>     <cfreturn httpresponse> 

and here webservice.cfm file content

  <!--- grab content request data post. --->   <cfset strcontent = trim( gethttprequestdata().content ) />   <cfdump var="#strcontent#" output="c:/webs/dump-b.txt">     <!--- check see if content valid xml document. --->   <cfif isxml( strcontent )>      <!---         parse xml data coldfusion xml         document object.      --->      <cfset xmlpost = xmlparse( strcontent ) />       <!---         check see if have xml nodes         need in order save file. our naming         purposes, need file extension ,         base64 data.      --->      <cfif (         structkeyexists( xmlpost.file, "ext" ) ,         structkeyexists( xmlpost.file, "base64" )         )>          <!---            assert: have nodes need, ,            demo, going assume            data values valid.         --->          <!---            create file name target file.            going use passed in extension , uuid.            make sure file name points executing            script directory (expandpath()).         --->         <!---         <cfset strfilename = expandpath(            createuuid() & "." &            xmlpost.file.ext.xmltext            ) />            --->         <cfset expandpath( createuuid()&'.'& xmlpost.file.ext.xmltext) />          <!---            grab base64 file data , convert            binary data.         --->         <cfset objbinarydata = tobinary(            xmlpost.file.base64.xmltext            ) />           <!--- write binary file data disk. --->         <cffile            action="write"            file="#strfilename#"            output="#objbinarydata#"            />                  </cfif>    </cfif>      

i testing on dev machine runs on windows 8 , coldfusion 10 (developer edition).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -