Beispiel #1
0
 def delete(self, user, size):
     """Delete personal image for user."""
     if valid_user(user):
         if remove_image(user):
             return 'Image deleted successfully'
         else:
             return 'Nothing to delete', 404
     else:
         return 'Unauthorized', 401
Beispiel #2
0
    def post(self, user, size):
        """Upload new image for user."""
        if valid_user(user):
            image = request.files['file']

            mimetype = from_buffer(image.stream.read(1024), mime=True)
            image.stream.seek(0)

            if image and mimetype in ALLOWED_TYPES:
                upload_image(user, image, mimetype)
                return 'Image uploaded successfully'
            else:
                return 'Unsupported media type', 415
        else:
            return 'Unauthorized', 401