开发者

How can I transfer a file via XMPP using Python?

开发者 https://www.devze.com 2022-12-30 08:57 出处:网络
I\'m using xmpppy l开发者_JAVA技巧ibrary for my jabber remote administration bot, but I can\'t find how to send/receive a file and save it inside the directory specified. The documentation is poor and

I'm using xmpppy l开发者_JAVA技巧ibrary for my jabber remote administration bot, but I can't find how to send/receive a file and save it inside the directory specified. The documentation is poor and there isn't any examples, but I really want to make it. Can anyone show some examples or some links about it? Or maybe I should use an alternative xmpp bindings?


There are two XEP's (XMPP Extensions) that cover file transfer: XEP-0096 http://xmpp.org/extensions/xep-0096.html (called SI (Stream Initiated) File Transfer) and XEP-0234 http://xmpp.org/extensions/xep-0234.html (Jingle File Transfer)

XEP-0096 is the original one but I have found it is rarely implemented (as you have discovered) in most libraries and also most clients. XEP-0234 is much newer and is found in more modern clients but not in older libraries (like xmpppy). The problem you are going to face even when you find a library or implementation of either of these is that both sides of the connection must also implement them.

Of the two, I would pick XEP-0234 because it covers quite a few issues that the original had and is considered to be the replace for it.

As far as Python libraries go none support it. I've looked at xmpppy, headstock, pyxmpp, jabber.py, twisted words and my favourite sleekxmppp.


There is a module xmpp.filetransfer in xmpppy:

This module contains IBB class that is the simple implementation of JEP-0047. Note that this is just a transport for data. You have to negotiate data transfer before (via StreamInitiation most probably). Unfortunately SI is not implemented yet.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号