问题
I'm using xmpppy library 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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/2851992/how-can-i-transfer-a-file-via-xmpp-using-python