Merge pull request #171 from fredronnv/master

Bugfix: filesize required for AsyncClient upload
This commit is contained in:
Ville Ranki 2021-08-31 12:22:56 +03:00 committed by GitHub
commit bb8c5196e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

2
bot.py
View File

@ -126,10 +126,10 @@ class Bot:
self.client: AsyncClient self.client: AsyncClient
response: UploadResponse response: UploadResponse
if blob: if blob:
(response, alist) = await self.client.upload(lambda a, b: url_or_bytes, blob_content_type)
i = Image.open(BytesIO(url_or_bytes)) i = Image.open(BytesIO(url_or_bytes))
image_length = len(url_or_bytes) image_length = len(url_or_bytes)
content_type = blob_content_type content_type = blob_content_type
(response, alist) = await self.client.upload(lambda a, b: url_or_bytes, blob_content_type, filesize=image_length)
else: else:
self.logger.debug(f"start downloading image from url {url_or_bytes}") self.logger.debug(f"start downloading image from url {url_or_bytes}")
headers = {'User-Agent': 'Mozilla/5.0'} headers = {'User-Agent': 'Mozilla/5.0'}