diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-03-08 12:11:26 +0100 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-03-08 12:11:26 +0100 |
commit | 29faf114a7031d5f2427ea73b862ce4e3b3fc04d (patch) | |
tree | 16a1e7b66d5f72a2bbd0d2c73eea0b4ef3944fe5 /examples | |
parent | 94ea8151d4dc795f2b544b67b4bc3f72379ccf31 (diff) | |
download | slixmpp-29faf114a7031d5f2427ea73b862ce4e3b3fc04d.tar.gz slixmpp-29faf114a7031d5f2427ea73b862ce4e3b3fc04d.tar.bz2 slixmpp-29faf114a7031d5f2427ea73b862ce4e3b3fc04d.tar.xz slixmpp-29faf114a7031d5f2427ea73b862ce4e3b3fc04d.zip |
Add max-file-size support to HTTP File Upload example.
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/http_upload.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/examples/http_upload.py b/examples/http_upload.py index 27b9d280..cbe4ab3f 100755 --- a/examples/http_upload.py +++ b/examples/http_upload.py @@ -53,7 +53,17 @@ class HttpUpload(slixmpp.ClientXMPP): self.disconnect() return - # TODO: check the maximum size from info_iq here. + for form in info_iq['disco_info'].iterables: + values = form['values'] + if values['FORM_TYPE'] == ['urn:xmpp:http:upload:0']: + max_file_size = int(values['max-file-size']) + if self.size > max_file_size: + log.error('File size bigger than max allowed') + self.disconnect() + return + break + else: + log.warn('Impossible to find max-file-size, assuming infinite storage space') log.info('Using service %s', info_iq['from']) slot_iq = yield from self['xep_0363'].request_slot( @@ -127,6 +137,7 @@ if __name__ == '__main__': xmpp = HttpUpload(args.jid, args.password, args.recipient, args.file) xmpp.register_plugin('xep_0071') + xmpp.register_plugin('xep_0128') xmpp.register_plugin('xep_0363') # Connect to the XMPP server and start processing XMPP stanzas. |