Hi all,
I am trying to transfer files via xmlrpc. I am following the example found here:
http://docs.python.org/library/xmlrpclib.html
under the binary objects section
Server Code
-
from SimpleXMLRPCServer import SimpleXMLRPCServer
-
import xmlrpclib
-
-
def python_logo():
-
handle = open("python_logo.jpg")
-
return xmlrpclib.Binary(handle.read())
-
handle.close()
-
-
server = SimpleXMLRPCServer(("localhost", 8000))
-
print "Listening on port 8000..."
-
server.register_function(python_logo, 'python_logo')
-
-
server.serve_forever()[FONT=Arial][/FONT]
Client Code
- import xmlrpclib
-
-
proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
-
handle = open("fetched_python_logo.jpg", "w")
-
handle.write(proxy.python_logo().data)
-
handle.close()
I can get txt files to transfer properly, but when I try to transfer other things like word documents and images it creates a file that are a fraction of the original size and nothing shows up when I open the file.
Am I missing something in my Python install that converts the binary objects properly?
Thanks.