我搜索了很多,但遗憾的是无法找到可行的解决方案。我有一个使用SleekXMPP模块的Python客户端,我想将PNG文件发送到Pidgin客户端。
AFAIK,尚未实施Jingle扩展,但使用IBB
,OOB
和BOB
的一些方法对我不起作用。我已尝试过XEP 0047
,0231
,0095
和0096
进行协商。
我将Pidgin设置为自动接受来自某个JID的文件。
使用SleekXMPP有没有办法做到这一点?
P.S。这本书XMPP: The definitive guide
也没有给我任何线索:/
感谢。
CODE
def upload_files_tgz(self, archivename, files, removearch=True):
# tar file name and mimetype (b for binary)
bfilename = "{0}.tar.gz".format(archivename)
bfilemime = "application/x-gzip";
# create a compressed tgz archive
tar = tarfile.open(bfilename, "w:gz" )
if files:
for f in files:
tar.add(f)
tar.close()
with open(bfilename, "rb") as compressed_file:
bin_output = compressed_file.read()
cid = self.xmpp_bot['xep_0231'].set_bob(bin_output, bfilemime)
msg = self.xmpp_bot.Message()
msg['to'] = self.get_xmpp_server_full_jid()
msg['bob']['cid'] = cid
msg['bob']['type'] = bfilemime
msg['bob']['data'] = bin_output
msg.send()
if removearch == True:
os.remove(bfilename)
def upload_image(self, filename, mimetype='image/png', message=None):
m = self.xmpp_bot.Message()
m['to'] = self.get_xmpp_server_full_jid()
m['type'] = 'chat'
with open(filename, 'rb') as img_file:
img = img_file.read()
if img:
cid = self.xmpp_bot['xep_0231'].set_bob(img, mimetype)
if message:
m['body'] = message
m['html']['body'] = '<img src="cid:%s" />' % cid
m.send()