From: Daniel Berger Date: 2005-01-18T06:01:06+09:00 Subject: Re: Bug in base64 decoder of xmlrpc? Lars Hoss wrote: > Hi, > > I am currently implementing support for the MetaWeblog/MovableType API > in my weblog engine. The API is simply a bunch of XML-RPC methods. One > method allows the uploading of files (metaWeblog.newMediaObject). In > order to send the binary file via XML-RPC the data gets base64 encoded. > The xmlrpc library automatically decodes the data. Writing the file to > disk looks something like this: > > def newMediaObject(blogid, username, password, data) > fileData = data["bits"] # Decoding is handled by xmlrpc automatically > File.open(data["name"], "wb") { |f| f.write(fileData) } > end > > The written data, however, is corrupted. Sometimes even some bytes are > missing. Uploading plain text files seems to be ok. But uploading arger > files such as JPEG files will result in corrupted data. The client I am > using is MarsEdit. > > Any suggestions? > > Regards, > Lars > > -- > "Stil ist die F�higkeit, komplizierte Dinge einfach zu sagen - nicht > umgekehrt." -- Cocteau, Jean I remember bringing something like this up with the author last year after reading Randy Ray's use.perl journal entry at http://use.perl.org/~rjray/journal/9899 and http://use.perl.org/~rjray/journal/9922. Randy Ray is the author of the Perl module RPC::XML, btw. This was Michael's response at the time (please correct me if things have changed Michael): "Implementing [Base64 streaming support] in xmlrpc4r is possible, but it would require some parts to be redesigned, especially where strings are returned (e.g. methodResponse). One problem is that the XML-RPC spec. requires the size of the XML-message to be known in the HTTP header (which is send first). Without this requirement, the whole XML-RPC message could be streamed out a socket." Whether anything has been done since then (about a year ago), I don't know. If this is unrelated, then I apologize for the noise. Regards, Dan