MediaTypeRefactor: Difference between revisions

From GNU MediaGoblin Wiki
Jump to navigation Jump to search
No edit summary
Line 12: Line 12:
=== Mime type ===
=== Mime type ===
Feeds etc need to be able to specify the mime type of a media file. Currently there is no way to get at the file's mime type. We'll need to think whether we store this per-file, simply in an extra field, or in an extra MimeType table? Or...?
Feeds etc need to be able to specify the mime type of a media file. Currently there is no way to get at the file's mime type. We'll need to think whether we store this per-file, simply in an extra field, or in an extra MimeType table? Or...?
<nowiki>16:13 < Elrond> We had a discussion on mimetype detection from bytes:
16:13 < Elrond> >>> import magic; ms = magic.open(magic.MAGIC_MIME_TYPE); ms.load();
ms.file("really_a_jpg.png")
16:13 < Elrond> 'image/jpeg'
16:14 < Elrond> Works also:
16:14 < Elrond> >>> ms.buffer(file("really_a_jpg.png").read(20))
16:14 < Elrond> 'image/jpeg'</nowiki>

Revision as of 15:47, 22 November 2012

We're planning to extend the media type system so that it's more like plugins. This page is to document some of the things we wish media types to be able to accomplish.

Accurately describe mimetype

In feeds and etc, we want to share the mimetype of the entry, and maybe of the individual files? Should this be on a per-entry or a per-filetype basis?

Additional field types

File size

For MRSS atom feeds (and probably also in the media "home" page, we need the file size of the media. Currently it is not stored at all. spaetz has a branch that implements a MediaEntry().file_size property. This works OK with local storages as it pulls the files and gets the file size on demand. But on remote storages (Amazon S3), we don't want to pull all files just to create the atom feed. We will therefore need to store the file size for each main media. Should this simply become part of the main MediaEntry table? Should it be part of an "extended Media Entry" table that is only queried on demand? I guess as we need this for all file types, so it does not make sense to put it in the per-type meta data table... Elrond says: I think, we should have filesizes stored in the MedaFiles table. Because each resolution has its own filesize.

Mime type

Feeds etc need to be able to specify the mime type of a media file. Currently there is no way to get at the file's mime type. We'll need to think whether we store this per-file, simply in an extra field, or in an extra MimeType table? Or...? 16:13 < Elrond> We had a discussion on mimetype detection from bytes: 16:13 < Elrond> >>> import magic; ms = magic.open(magic.MAGIC_MIME_TYPE); ms.load(); ms.file("really_a_jpg.png") 16:13 < Elrond> 'image/jpeg' 16:14 < Elrond> Works also: 16:14 < Elrond> >>> ms.buffer(file("really_a_jpg.png").read(20)) 16:14 < Elrond> 'image/jpeg'