summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0363/http_upload.py
diff options
context:
space:
mode:
Diffstat (limited to 'slixmpp/plugins/xep_0363/http_upload.py')
-rw-r--r--slixmpp/plugins/xep_0363/http_upload.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/slixmpp/plugins/xep_0363/http_upload.py b/slixmpp/plugins/xep_0363/http_upload.py
index 65894975..2228ca8b 100644
--- a/slixmpp/plugins/xep_0363/http_upload.py
+++ b/slixmpp/plugins/xep_0363/http_upload.py
@@ -6,7 +6,6 @@
See the file LICENSE for copying permission.
"""
-import asyncio
import logging
import os.path
@@ -68,12 +67,18 @@ class XEP_0363(BasePlugin):
def _handle_request(self, iq):
self.xmpp.event('http_upload_request', iq)
- async def find_upload_service(self, timeout=None):
- results = await self.xmpp['xep_0030'].get_info_from_domain()
+ async def find_upload_service(self, domain=None, timeout=None):
+ results = await self.xmpp['xep_0030'].get_info_from_domain(
+ domain=domain, timeout=timeout)
+ candidates = []
for info in results:
for identity in info['disco_info']['identities']:
if identity[0] == 'store' and identity[1] == 'file':
+ candidates.append(info)
+ for info in candidates:
+ for feature in info['disco_info']['features']:
+ if feature == Request.namespace:
return info
def request_slot(self, jid, filename, size, content_type=None, ifrom=None,
@@ -90,11 +95,12 @@ class XEP_0363(BasePlugin):
timeout_callback=timeout_callback)
async def upload_file(self, filename, size=None, content_type=None, *,
- input_file=None, ifrom=None, timeout=None,
+ input_file=None, ifrom=None, domain=None, timeout=None,
callback=None, timeout_callback=None):
''' Helper function which does all of the uploading process. '''
if self.upload_service is None:
- info_iq = await self.find_upload_service(timeout=timeout)
+ info_iq = await self.find_upload_service(
+ domain=domain, timeout=timeout)
if info_iq is None:
raise UploadServiceNotFound()
self.upload_service = info_iq['from']
@@ -125,7 +131,8 @@ class XEP_0363(BasePlugin):
basename = os.path.basename(filename)
slot_iq = await self.request_slot(self.upload_service, basename, size,
- content_type, ifrom, timeout)
+ content_type, ifrom, timeout,
+ timeout_callback=timeout_callback)
slot = slot_iq['http_upload_slot']
headers = {