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

Comments

dave reid’s picture

We should also fix file_get_type() to use this logic rather than the silly claim callback magic.

aaron’s picture

yes to both of these! makes sense.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new1.76 KB

Sweet, 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.

dave reid’s picture

StatusFileSize
new3.51 KB

Updated with changes to file_get_type() and file_presave_file().

dave reid’s picture

StatusFileSize
new3.62 KB
dave reid’s picture

StatusFileSize
new3.72 KB

Ok think I'm finally happy with this one.

dave reid’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

kenorb’s picture

Version: 7.x-1.x-dev » 8.x-2.x-dev
Assigned: dave reid » Unassigned
Issue summary: View changes