Sending a file to a remote server.

Fredrik Lundh fredrik at pythonware.com
Sun Apr 2 18:44:57 EDT 2006


Jose Carlos Balderas Alberico wrote:

> Hi. I posted a message in the list a couple of days ago about sending a file
> to a remote SimpleXMLRPCServer. Well. my doubt still remains, so I come to
> you again in search of a clearer answer.
>
> The thing is I want to send a ZIP file to a server, and what I basically do
> is enclose the file data into a Binary object by doing something like "data
> = Binary(f.read())". Then I call a function in the server, passing the
> object as a parameter, and have the server process the same file by doing
> something like
>
> f = open("somefile.zip", 'w')
> f.write(binaryObject.data)
>
> Since I've never programmed server/client before, I've never faced the fact
> of sending a file to a remote machine.
>
> I just want to know if what I've done to send the file is acceptable, and if
> you know of a better way to send files to a SimpleXMLRPCServer.

since ZIP files can contain arbitrary data, wrapping the data in the Binary
wrapper is the only way to you can transfer it over XML-RPC.

note, however, that XML-RPC (as well as any other XML-based transport)
needs to encode the bytes, which typically adds ~33% overhead.

if you're on a slow connection, or your files are really large, plain HTTP
transfers (or rsync etc.) are more efficient (but often somewhat harder
to implement).

</F>






More information about the Python-list mailing list