# HG changeset patch # User Goffi # Date 1605189195 -3600 # Node ID 0957ea9137b87b4ffc268340a18f2e4fc8d4a04d # Parent e898a43b5bea131ab98f2095ae5c729957f44dd0 plugin XEP-0047: fixed file reading and content encoding diff -r e898a43b5bea -r 0957ea9137b8 sat/plugins/plugin_xep_0047.py --- a/sat/plugins/plugin_xep_0047.py Thu Nov 12 14:53:15 2020 +0100 +++ b/sat/plugins/plugin_xep_0047.py Thu Nov 12 14:53:15 2020 +0100 @@ -327,7 +327,8 @@ """ session_data["timer"].reset(TIMEOUT) - buffer_ = session_data["stream_object"].read(session_data["block_size"]) + # FIXME: producer/consumer mechanism is not used properly here + buffer_ = session_data["stream_object"].file_obj.read(session_data["block_size"]) if buffer_: next_iq_elt = client.IQ() next_iq_elt["from"] = session_data["local_jid"].full() @@ -336,7 +337,7 @@ seq = session_data["seq"] = (session_data["seq"] + 1) % 65535 data_elt["seq"] = str(seq) data_elt["sid"] = session_data["id"] - data_elt.addContent(base64.b64encode(buffer_)) + data_elt.addContent(base64.b64encode(buffer_).decode()) args = [session_data, client] d = next_iq_elt.send() d.addCallbacks(self._IQDataStreamCb, self._IQDataStreamEb, args, None, args)