Opened 9 years ago

Last modified 5 years ago

#5444 in_progress defect

Implement 'type_match_handler' hook for all core media types

Reported by: ayleph Owned by: ayleph
Priority: major Milestone:
Component: programming Keywords: processing, sniffing
Cc: Boris Bobrov Parent Tickets:

Description

Since the gstreamer-1.0 update, uploaded media are sniffed and very often (always?) produce messages like below, even when the media are successfully processed. Breton says this is not intentional and should be addressed.

No plugins handled extension .jpg

Attachments (1)

image_sniffing_#5444.patch (2.2 KB ) - added by Ben Sturmfels 5 years ago.
Quick hack to allow upload of image files without file extensions. Doesn't fully address this ticket.

Download all attachments as: .zip

Change History (6)

comment:1 by ayleph, 9 years ago

This error comes from mediagoblin/media_types/__init__.py

def type_match_handler(media_file, filename):
    ...
    if os.path.basename(filename).find('.') > 0:
        ...
        hook_result = hook_handle('type_match_handler', ext[1:])
        if hook_result:
        ...
        else:
            _log.info('No plugins handled extension {0}'.format(ext))
    else:
        _log.info('File {0} has no known file extension, let\'s hope '
                'the sniffers get it.'.format(filename))
    raise TypeNotFound(_(u'Sorry, I don\'t support that file type :('))

Doing a search through code for type_match_handler shows that only the video mediatype provides this hook, while all of the other media types still use the deprecated get_media_type_and_manager hook.

If get_media_type_and_manager is really deprecated, then maybe all of the other mediatypes should be updated to support type_match_handler. I'm not sure if that's the cause of this issue or if it's a separate issue that also needs to be addressed.

comment:2 by ayleph, 7 years ago

Summary: No plugins handled extensionImplement 'type_match_handler' hook for all core media types

I stumbled across this again and it's still an issue. We should implement the type_match_handler hook for other media types as well. I've changed the ticket summary to reflect this.

comment:3 by ayleph, 7 years ago

Owner: set to ayleph
Status: newin_progress

comment:4 by Ben Sturmfels, 5 years ago

The "image" media type currently conflates the process of identifying by file extension and checking the file content. Before I'd seen this ticket I wrote a small patch to allow uploading images without file extensions - see attachment. This skips the file extension check entirely and relies on sniff_handler trying to open the image.

The feature here that's most important to me is that we can accept any file, with or without a file extension and generally do the right thing.

by Ben Sturmfels, 5 years ago

Attachment: image_sniffing_#5444.patch added

Quick hack to allow upload of image files without file extensions. Doesn't fully address this ticket.

comment:5 by Ben Sturmfels, 5 years ago

See also #5318 which is about errors caused when a .gif file is incorrectly named with .jpg extension. We need a robust solution that can take anything people throw at us (assuming we have the tech to transcode it).

Note: See TracTickets for help on using tickets.