aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/plugins/api/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'mediagoblin/plugins/api/views.py')
-rw-r--r--mediagoblin/plugins/api/views.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/mediagoblin/plugins/api/views.py b/mediagoblin/plugins/api/views.py
index 2055a663..9159fe65 100644
--- a/mediagoblin/plugins/api/views.py
+++ b/mediagoblin/plugins/api/views.py
@@ -18,7 +18,6 @@ import json
import logging
from os.path import splitext
-from werkzeug.datastructures import FileStorage
from werkzeug.exceptions import BadRequest, Forbidden
from werkzeug.wrappers import Response
@@ -27,7 +26,8 @@ from mediagoblin.meddleware.csrf import csrf_exempt
from mediagoblin.media_types import sniff_media
from mediagoblin.plugins.api.tools import api_auth, get_entry_serializable, \
json_response
-from mediagoblin.submit.lib import prepare_queue_task, run_process_media
+from mediagoblin.submit.lib import check_file_field, prepare_queue_task, \
+ run_process_media, new_upload_entry
_log = logging.getLogger(__name__)
@@ -45,9 +45,7 @@ def post_entry(request):
_log.debug('Must POST against post_entry')
raise BadRequest()
- if not 'file' in request.files \
- or not isinstance(request.files['file'], FileStorage) \
- or not request.files['file'].stream:
+ if not check_file_field(request, 'file'):
_log.debug('File field not found')
raise BadRequest()
@@ -55,7 +53,7 @@ def post_entry(request):
media_type, media_manager = sniff_media(media_file)
- entry = request.db.MediaEntry()
+ entry = new_upload_entry(request.user)
entry.media_type = unicode(media_type)
entry.title = unicode(request.form.get('title')
or splitext(media_file.filename)[0])
@@ -63,8 +61,6 @@ def post_entry(request):
entry.description = unicode(request.form.get('description'))
entry.license = unicode(request.form.get('license', ''))
- entry.uploader = request.user.id
-
entry.generate_slug()
# queue appropriately