Permalink
Browse files

Merge pull request #14 from tarekziade/master

using mimetypes to guess the mimetype of uploaded screenshots
  • Loading branch information...
2 parents 0138680 + 8e0b3ce commit b6ce52660b121c549d66816cbf7472b14ab2ce8f @zalun zalun committed Sep 20, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 python/lib/marketplace.py
View
@@ -9,6 +9,7 @@
import logging
import time
import urllib
+import mimetypes
from base64 import b64encode
@@ -240,10 +241,13 @@ def create_screenshot(self, app_id, filename, position=1):
s_content = s_file.read()
s_encoded = b64encode(s_content)
url = self.url('create_screenshot') % app_id
- # TODO find the mimetype of the file
- mimetype = 'image/jpg'
+
+ mtype, encoding = mimetypes.guess_type(filename)
+ if mtype is None:
+ mtype = 'image/jpeg'
+
data = {'position': position,
- 'file': {'type': mimetype,
+ 'file': {'type': mtype,
'data': s_encoded}}
return self.post(url, data)

0 comments on commit b6ce526

Please sign in to comment.