If a user installs the file_entity module after having uploaded some files, the records in {file_managed}.type will be empty strings. I propose that we update all records using the content type part of {file_managed}.filemime.
The list of types according to http://www.iana.org/assignments/media-types/index.html are the following, which I think give us a good range of types:
application
audio
example
image
message
model
multipart
text
video
So for example:
file type | mime | resulting {file_managed}.type value
jpeg | image/jpeg | image
png | image/png | image
txt | text/plain | text
pdf | application/pdf | application
mp3 | audio/mpeg3 | audio
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 1227080-update-empty-file-types.patch | 3.72 KB | dave reid |
| #5 | 1227080-update-empty-file-types.patch | 3.62 KB | dave reid |
| #4 | 1227080-update-empty-file-types.patch | 3.51 KB | dave reid |
| #3 | 1227080-update-empty-file-types.patch | 1.76 KB | dave reid |
Comments
Comment #1
dave reidWe should also fix file_get_type() to use this logic rather than the silly claim callback magic.
Comment #2
aaron commentedyes to both of these! makes sense.
Comment #3
dave reidSweet, I finally found the right cross-platform function so that this can be done with just one SQL query! Patch provided and tested on SQLite and MySQL.
Comment #4
dave reidUpdated with changes to file_get_type() and file_presave_file().
Comment #5
dave reidComment #6
dave reidOk think I'm finally happy with this one.
Comment #7
dave reidTested manually again and it works great. Committed to Git.
http://drupalcode.org/project/file_entity.git/commit/0740af8
http://drupalcode.org/project/file_entity.git/commit/5399ebb
Follow-up issue for Media 7.x-2.x: #1227902: Remove code that handles file 'types'
Comment #9
kenorb commented