mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Fix bug with uploading file-like objects.
I would require bytes-like objects instead due to its usage inside the HTTPClient. Release this restriction so old `send_file` code works.
This commit is contained in:
parent
64c1e7d199
commit
f3b257b342
@ -49,7 +49,7 @@ import aiohttp
|
|||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
import logging, traceback
|
import logging, traceback
|
||||||
import sys, re
|
import sys, re, io
|
||||||
import tempfile, os, hashlib
|
import tempfile, os, hashlib
|
||||||
import itertools
|
import itertools
|
||||||
import datetime
|
import datetime
|
||||||
@ -873,7 +873,7 @@ class Client:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
with open(fp, 'rb') as f:
|
with open(fp, 'rb') as f:
|
||||||
buffer = f.read()
|
buffer = io.BytesIO(f.read())
|
||||||
if filename is None:
|
if filename is None:
|
||||||
filename = fp
|
filename = fp
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
@ -29,7 +29,6 @@ import asyncio
|
|||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import io
|
|
||||||
import inspect
|
import inspect
|
||||||
import weakref
|
import weakref
|
||||||
from random import randint as random_integer
|
from random import randint as random_integer
|
||||||
@ -239,7 +238,7 @@ class HTTPClient:
|
|||||||
form.add_field('content', str(content))
|
form.add_field('content', str(content))
|
||||||
|
|
||||||
form.add_field('tts', 'true' if tts else 'false')
|
form.add_field('tts', 'true' if tts else 'false')
|
||||||
form.add_field('file', io.BytesIO(buffer), filename=filename, content_type='application/octet-stream')
|
form.add_field('file', buffer, filename=filename, content_type='application/octet-stream')
|
||||||
|
|
||||||
return self.post(url, data=form, bucket='messages:' + str(guild_id))
|
return self.post(url, data=form, bucket='messages:' + str(guild_id))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user