[Twisted-Python] Sending jpeg data over TCP/IP
Maarten ter Huurne
maarten at treewalker.org
Sat Feb 13 17:02:25 MST 2010
On Sunday 14 February 2010, gary clark wrote:
> I want to send raw binary data but also text in the message. I am
> currently sending ascii data to the twisted server via open-ssl. Its
> great and twisted is cool. However I want to send a name of document and
> then the raw data in the same message? Is this possible with twisted.
> Essentially I want to store the file in a location based upon its name.
> Is this even practical to do this? Not sure.
Unless you really cannot open a new TCP connection, the HTTP PUT command
sounds like a good option for this. If you need more file management
operations later, you could adopt the WebDAV extensions to HTTP:
http://en.wikipedia.org/wiki/Webdav
> Say for instance
>
> <FILENAME>gazza.doc</FILENAME>
> <RAWDATA>0101110100101010010010110010101010101101010</RAWDATA>
>
> I dont know if the SAX parser which I am using could parse this data?
You could use base64 encoding: put all the data in a Python string and call
"s.encode('base64')".
Bye,
Maarten
More information about the Twisted-Python
mailing list