aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/plugins/api/views.py
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-09-17 23:54:27 +0200
committerJoar Wandborg <git@wandborg.com>2012-09-17 23:54:27 +0200
commit09e528acbb4d1321fce5cec8b22fd7fd153bf68a (patch)
tree0697f41fb689d66b5065eb08d1980b527680800f /mediagoblin/plugins/api/views.py
parentc92aa0d0b21e01223db7eeaa2fcea4d961b512d9 (diff)
downloadmediagoblin-09e528acbb4d1321fce5cec8b22fd7fd153bf68a.tar.lz
mediagoblin-09e528acbb4d1321fce5cec8b22fd7fd153bf68a.tar.xz
mediagoblin-09e528acbb4d1321fce5cec8b22fd7fd153bf68a.zip
Fixed validation in API post_entry.
Added state to API get_entry_serializable
Diffstat (limited to 'mediagoblin/plugins/api/views.py')
-rw-r--r--mediagoblin/plugins/api/views.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py
index 2eb9e414..d537ec6e 100644
--- a/mediagoblin/plugins/api/views.py
+++ b/mediagoblin/plugins/api/views.py
@@ -20,6 +20,7 @@ import uuid
from os.path import splitext
from webob import exc, Response
+from cgi import FieldStorage
from werkzeug.utils import secure_filename
from celery import registry
@@ -43,10 +44,18 @@ _log = logging.getLogger(__name__)
@require_active_login
def post_entry(request):
_log.debug('Posting entry')
+
+ if request.method == 'OPTIONS':
+ return json_response({'status': 200})
+
if request.method != 'POST':
+ _log.debug('Must POST against post_entry')
return exc.HTTPBadRequest()
- if not 'file' in request.POST or not hasattr(request.POST['file'], 'file'):
+ if not 'file' in request.POST \
+ or not isinstance(request.POST['file'], FieldStorage) \
+ or not request.POST['file'].file:
+ _log.debug('File field not found')
return exc.HTTPBadRequest()
media_file = request.POST['file']