plugin XEP-0363: fixed fileHTTPUploadGetSlot
This commit is contained in:
parent
9ba6df5503
commit
e712981938
1 changed files with 7 additions and 5 deletions
|
|
@ -93,7 +93,7 @@ class XEP_0363:
|
|||
"fileHTTPUploadGetSlot",
|
||||
".plugin",
|
||||
in_sign="sisss",
|
||||
out_sign="(ss)",
|
||||
out_sign="(ssaa{ss})",
|
||||
method=self._getSlot,
|
||||
async_=True,
|
||||
)
|
||||
|
|
@ -272,15 +272,17 @@ class XEP_0363:
|
|||
This method can be used when uploading is done by the frontend
|
||||
@param filename(unicode): name of the file to upload
|
||||
@param size(int): size of the file (must be non null)
|
||||
@param upload_jid(jid.JID(), None, ''): HTTP upload capable entity
|
||||
@param upload_jid(str, ''): HTTP upload capable entity
|
||||
@param content_type(unicode, None): MIME type of the content
|
||||
empty string or None to guess automatically
|
||||
"""
|
||||
client = self.host.getClient(profile_key)
|
||||
filename = filename.replace("/", "_")
|
||||
return defer.ensureDeferred(self.getSlot(
|
||||
client, filename, size, content_type or None, upload_jid or None
|
||||
d = defer.ensureDeferred(self.getSlot(
|
||||
client, filename, size, content_type or None, jid.JID(upload_jid) or None
|
||||
))
|
||||
d.addCallback(lambda slot: (slot.get, slot.put, slot.headers))
|
||||
return d
|
||||
|
||||
async def getSlot(self, client, filename, size, content_type=None, upload_jid=None):
|
||||
"""Get a slot (i.e. download/upload links)
|
||||
|
|
@ -304,7 +306,7 @@ class XEP_0363:
|
|||
try:
|
||||
upload_jid = client.http_upload_service
|
||||
except AttributeError:
|
||||
found_entity = await self.getHTTPUploadEntity(profile=client.profile)
|
||||
found_entity = await self.getHTTPUploadEntity(client)
|
||||
return await self.getSlot(
|
||||
client, filename, size, content_type, found_entity)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue