Permalink
Browse files

guessing the mimetype

  • Loading branch information...
1 parent 0138680 commit 6c857cd0890edc781d5ecfd091b7a1758c189dff @tarekziade tarekziade committed Sep 20, 2012
Showing with 8 additions and 4 deletions.
  1. +1 −1 python/app/config.py
  2. +7 −3 python/lib/marketplace.py
View
@@ -10,6 +10,6 @@
MARKETPLACE_PORT = (environ['MARKETPLACE_PORT']
if 'MARKETPLACE_PORT' in environ else 443)
MARKETPLACE_DOMAIN = (environ['MARKETPLACE_DOMAIN']
- if 'MARKETPLACE_DOMAIN' in environ else 'marketplace-dev.allizom.org')
+ if 'MARKETPLACE_DOMAIN' in environ else 'marketplace.allizom.org')
MARKETPLACE_PROTOCOL = (environ['MARKETPLACE_PROTOCOL']
if 'MARKETPLACE_PROTOCOL' in environ else 'https')
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 6c857cd

Please sign in to comment.