MIMEDETECT DRUPAL MODULE
========================
CONTENTS OF THIS FILE
---------------------
* Summary
* Requirements
* Installation
* Configuration
* Usage
* Drupal 6 upgrade
* Recommended modules
* Troubleshooting
* Contact
* Credits
SUMMARY
-------
MimeDetect provides a mime detection API.
Detection service is primarely based on fileinfo PHP extension and on UNIX file
command as secondary method. It also improves default Drupal mimetype detection
based on filename extension.
MimeDetect also includes a simple submodule for file upload protection against
inconsistent filename extension and its real content.
REQUIREMENTS
------------
At least one of these two supported tools based on MIME 'magic' detection has to
be present in your system:
1. PHP File information extension
Commonly included in the basic PHP installation.
see: http://php.net/manual/en/book.fileinfo.php
2. UNIX 'file' command
Present on most UNIX/Linux systems.
see: https://en.wikipedia.org/wiki/File_(command)
INSTALLATION
------------
Install as usual, see https://www.drupal.org/node/895232 for further
information.
CONFIGURATION
-------------
Module configuration is available at Admin -> Configuration -> Media
(/admin/config/media/mimedetect).
By default, only the PHP fileinfo detection engine is enabled.
USAGE
-----
MimeDetect acts as an API, other modules can make usage of it by calling
'mimedetect_mime' function.
A simple file upload validator is included in a separate module for illustration
purposes, basic functionality and backward compatibility with Drupal 6. It
rejects any file upload which detected MIME type doesn't match the filename
extension.
DRUPAL 6 UPGRADE
----------------
Drupal 6 filefield module (https://www.drupal.org/project/filefield) had
integration with MimeDetect. This module is now part of the Drupal 7 core, so
the integration with non-core (third-party) modules like MimeDetect was lost.
This functionality is now provided by the "MimeDetect file upload validator"
module, included as a submodule.
RECOMMENDED MODULES
-------------------
* File MIME (https://www.drupal.org/project/filemime):
Provides a way to alter the core MIME type mapping to file name extensions.
Use it to add unrecognized extensions or to alter the MIME associated with
a particular extension. Some known unrecognized extensions by Drupal core
are:
Audio types:
.rmi (audio/midi)
.aidff (audio/x-aiff)
Image types:
.cod (image/cis-cod)
.jfif (image/pipeg)
.cmx (image/x-cmx)
Video types:
.mpa (video/mpeg)
.mpv2 (video/mpeg)
.asr (video/x-ms-asf)
TROUBLESHOOTING
---------------
* Updating from older versions:
Previous versions of MimeDetect (7.x-1.0 and older) were distributed with a
Magic database file to make FileInfo based MIME detection more consistent
across servers. Due to that different PHP version expect different 'magic'
file format, there were frequently errors on installation and after PHP
version updates, so this database has been removed in favor of the default
magic information available in system server or bundled with PHP fileinfo
extension.
This change affects only the default behaviour; if your website is
configured to use a custom magic, MimeDetect will be still running with it.
For the default behaviour, might be slight differences in MIME type
detection since the magic information is now taken from system or PHP, not
from the old provided magic file. In any case, default behaviour should be
now more accurate.
* File upload validation with unrecognized file name extensions:
Drupal core maps each file extension with a MIME type. Thats the way the
file_get_mimetype() function guesses the MIME type for a given file name.
Some file name extensions are not present on such map or can be mapped with
a different MIME type than the detected by MimeDetect. For example, that's
the case for portable object (".po") files. PO files are plain text files
that contain translation strings. Drupal core returns the generic
'application/octet-stream' MIME type for them, whereas 'magic' MIME
detection engines (and therefore MimeDetect) usually returns 'text/x-po' as
the detected MIME type.
This mismatch will make file upload validator to block file uploading. The
right way to solve this is by altering the Drupal core file name extension
map, adding the unrecognized MIME types or overriding existing ones. And
that's exactly what the recommended filemime module does, so you will find
this module useful to solve these scenarios.
CONTACT
-------
Current maintainers:
* Manuel Adan (manuel.adan) - https://www.drupal.org/user/516420
CREDITS
-------
Ported to D6 & D7 by:
* Andrew Morton (drewish) - https://www.drupal.org/user/34869
Created by:
* Darrel O'Pry (dopry) - https://www.drupal.org/user/22202
View source
- MIMEDETECT DRUPAL MODULE
- ========================
-
- CONTENTS OF THIS FILE
- ---------------------
-
- * Summary
- * Requirements
- * Installation
- * Configuration
- * Usage
- * Drupal 6 upgrade
- * Recommended modules
- * Troubleshooting
- * Contact
- * Credits
-
-
- SUMMARY
- -------
-
- MimeDetect provides a mime detection API.
-
- Detection service is primarely based on fileinfo PHP extension and on UNIX file
- command as secondary method. It also improves default Drupal mimetype detection
- based on filename extension.
-
- MimeDetect also includes a simple submodule for file upload protection against
- inconsistent filename extension and its real content.
-
-
- REQUIREMENTS
- ------------
-
- At least one of these two supported tools based on MIME 'magic' detection has to
- be present in your system:
-
- 1. PHP File information extension
- Commonly included in the basic PHP installation.
- see: http://php.net/manual/en/book.fileinfo.php
-
- 2. UNIX 'file' command
- Present on most UNIX/Linux systems.
- see: https://en.wikipedia.org/wiki/File_(command)
-
-
- INSTALLATION
- ------------
-
- Install as usual, see https://www.drupal.org/node/895232 for further
- information.
-
-
- CONFIGURATION
- -------------
-
- Module configuration is available at Admin -> Configuration -> Media
- (/admin/config/media/mimedetect).
-
- By default, only the PHP fileinfo detection engine is enabled.
-
-
- USAGE
- -----
-
- MimeDetect acts as an API, other modules can make usage of it by calling
- 'mimedetect_mime' function.
-
- A simple file upload validator is included in a separate module for illustration
- purposes, basic functionality and backward compatibility with Drupal 6. It
- rejects any file upload which detected MIME type doesn't match the filename
- extension.
-
-
- DRUPAL 6 UPGRADE
- ----------------
-
- Drupal 6 filefield module (https://www.drupal.org/project/filefield) had
- integration with MimeDetect. This module is now part of the Drupal 7 core, so
- the integration with non-core (third-party) modules like MimeDetect was lost.
-
- This functionality is now provided by the "MimeDetect file upload validator"
- module, included as a submodule.
-
-
- RECOMMENDED MODULES
- -------------------
-
- * File MIME (https://www.drupal.org/project/filemime):
- Provides a way to alter the core MIME type mapping to file name extensions.
- Use it to add unrecognized extensions or to alter the MIME associated with
- a particular extension. Some known unrecognized extensions by Drupal core
- are:
-
- Audio types:
- .rmi (audio/midi)
- .aidff (audio/x-aiff)
-
- Image types:
- .cod (image/cis-cod)
- .jfif (image/pipeg)
- .cmx (image/x-cmx)
-
- Video types:
- .mpa (video/mpeg)
- .mpv2 (video/mpeg)
- .asr (video/x-ms-asf)
-
-
- TROUBLESHOOTING
- ---------------
-
- * Updating from older versions:
-
- Previous versions of MimeDetect (7.x-1.0 and older) were distributed with a
- Magic database file to make FileInfo based MIME detection more consistent
- across servers. Due to that different PHP version expect different 'magic'
- file format, there were frequently errors on installation and after PHP
- version updates, so this database has been removed in favor of the default
- magic information available in system server or bundled with PHP fileinfo
- extension.
-
- This change affects only the default behaviour; if your website is
- configured to use a custom magic, MimeDetect will be still running with it.
-
- For the default behaviour, might be slight differences in MIME type
- detection since the magic information is now taken from system or PHP, not
- from the old provided magic file. In any case, default behaviour should be
- now more accurate.
-
- * File upload validation with unrecognized file name extensions:
-
- Drupal core maps each file extension with a MIME type. Thats the way the
- file_get_mimetype() function guesses the MIME type for a given file name.
-
- Some file name extensions are not present on such map or can be mapped with
- a different MIME type than the detected by MimeDetect. For example, that's
- the case for portable object (".po") files. PO files are plain text files
- that contain translation strings. Drupal core returns the generic
- 'application/octet-stream' MIME type for them, whereas 'magic' MIME
- detection engines (and therefore MimeDetect) usually returns 'text/x-po' as
- the detected MIME type.
-
- This mismatch will make file upload validator to block file uploading. The
- right way to solve this is by altering the Drupal core file name extension
- map, adding the unrecognized MIME types or overriding existing ones. And
- that's exactly what the recommended filemime module does, so you will find
- this module useful to solve these scenarios.
-
-
- CONTACT
- -------
-
- Current maintainers:
- * Manuel Adan (manuel.adan) - https://www.drupal.org/user/516420
-
-
- CREDITS
- -------
-
- Ported to D6 & D7 by:
- * Andrew Morton (drewish) - https://www.drupal.org/user/34869
-
- Created by:
- * Darrel O'Pry (dopry) - https://www.drupal.org/user/22202