aboutsummaryrefslogtreecommitdiff
path: root/discord/utils.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-11-26 22:14:04 -0500
committerRapptz <[email protected]>2015-11-26 22:14:04 -0500
commitf0617fbb6a944601f36cd86a7feef241e370b582 (patch)
tree5fb130f740c42bd939914b8a9e92ac3514ae6a4f /discord/utils.py
parentMove _null_event and _verify_successful_response to utils (diff)
downloaddiscord.py-f0617fbb6a944601f36cd86a7feef241e370b582.tar.xz
discord.py-f0617fbb6a944601f36cd86a7feef241e370b582.zip
Add support for uploading avatars.
Diffstat (limited to 'discord/utils.py')
-rw-r--r--discord/utils.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/discord/utils.py b/discord/utils.py
index 38a00bdc..423ddc8a 100644
--- a/discord/utils.py
+++ b/discord/utils.py
@@ -25,7 +25,7 @@ DEALINGS IN THE SOFTWARE.
"""
from re import split as re_split
-from .errors import HTTPException
+from .errors import HTTPException, InvalidArgument
import datetime
@@ -65,3 +65,11 @@ def _verify_successful_response(response):
success = code >= 200 and code < 300
if not success:
raise HTTPException(response)
+
+def _get_mime_type_for_image(data):
+ if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
+ return 'image/png'
+ elif data.startswith(b'\xFF\xD8') and data.endswith(b'\xFF\xD9'):
+ return 'image/jpeg'
+ else:
+ raise InvalidArgument('Unsupported image type given')