Add new hook for two-step media type checking
Before uploaded media files were checked by extension. This led to situations when a plugin can support file with specific extension but doesn't due to lack of codecs, for example. Since the plugin reported that it supports uploaded file type, the upload was being declared successful, but transcoding failed. The failures were not easy to debug. The change adds a new hook that could allow two-step checking of the content. The result of the hook execution returns a tuple with media type name, manager and a callable sniffer, that can be used to perform probably expensive checks of the content. Also the change adds implementation of the hook for video.
This commit is contained in:
@@ -29,8 +29,7 @@ from mediagoblin.tools.response import render_to_response, redirect
|
||||
from mediagoblin.decorators import require_active_login, user_has_privilege
|
||||
from mediagoblin.submit import forms as submit_forms
|
||||
from mediagoblin.messages import add_message, SUCCESS
|
||||
from mediagoblin.media_types import \
|
||||
InvalidFileType, FileTypeNotSupported
|
||||
from mediagoblin.media_types import FileTypeNotSupported
|
||||
from mediagoblin.submit.lib import \
|
||||
check_file_field, submit_media, get_upload_file_limits, \
|
||||
FileUploadLimit, UserUploadLimit, UserPastUploadLimit
|
||||
@@ -89,18 +88,10 @@ def submit_start(request):
|
||||
_('Sorry, you have reached your upload limit.'))
|
||||
return redirect(request, "mediagoblin.user_pages.user_home",
|
||||
user=request.user.username)
|
||||
|
||||
except FileTypeNotSupported as e:
|
||||
submit_form.file.errors.append(e)
|
||||
except Exception as e:
|
||||
'''
|
||||
This section is intended to catch exceptions raised in
|
||||
mediagoblin.media_types
|
||||
'''
|
||||
if isinstance(e, InvalidFileType) or \
|
||||
isinstance(e, FileTypeNotSupported):
|
||||
submit_form.file.errors.append(
|
||||
e)
|
||||
else:
|
||||
raise
|
||||
raise
|
||||
|
||||
return render_to_response(
|
||||
request,
|
||||
|
||||
Reference in New Issue
Block a user