Created
May 22, 2010 19:37
-
-
Save maetl/410303 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiHandler(webapp.RequestHandler): | |
def check_uploaded_picture(self): | |
if not self.check_api_key(): | |
self.error_response(401, API_ERROR_UNAUTHORIZED) | |
return False | |
if not self.request.get('picture'): | |
self.error_response(400, API_ERROR_MISSING) | |
return False | |
if not self.check_picture_type(self.request.POST['picture']): | |
self.error_response(400, API_ERROR_INVALID) | |
return False | |
return True | |
def check_picture_type(self, picture): | |
return picture.type in ['image/jpeg', 'image/png', 'image/gif'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment