You are here

README.txt in MimeDetect 7

Same filename and directory in other branches
  1. 8 README.txt
  2. 5 README.txt
  3. 6 README.txt
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

File

README.txt
View source
  1. MIMEDETECT DRUPAL MODULE
  2. ========================
  3. CONTENTS OF THIS FILE
  4. ---------------------
  5. * Summary
  6. * Requirements
  7. * Installation
  8. * Configuration
  9. * Usage
  10. * Drupal 6 upgrade
  11. * Recommended modules
  12. * Troubleshooting
  13. * Contact
  14. * Credits
  15. SUMMARY
  16. -------
  17. MimeDetect provides a mime detection API.
  18. Detection service is primarely based on fileinfo PHP extension and on UNIX file
  19. command as secondary method. It also improves default Drupal mimetype detection
  20. based on filename extension.
  21. MimeDetect also includes a simple submodule for file upload protection against
  22. inconsistent filename extension and its real content.
  23. REQUIREMENTS
  24. ------------
  25. At least one of these two supported tools based on MIME 'magic' detection has to
  26. be present in your system:
  27. 1. PHP File information extension
  28. Commonly included in the basic PHP installation.
  29. see: http://php.net/manual/en/book.fileinfo.php
  30. 2. UNIX 'file' command
  31. Present on most UNIX/Linux systems.
  32. see: https://en.wikipedia.org/wiki/File_(command)
  33. INSTALLATION
  34. ------------
  35. Install as usual, see https://www.drupal.org/node/895232 for further
  36. information.
  37. CONFIGURATION
  38. -------------
  39. Module configuration is available at Admin -> Configuration -> Media
  40. (/admin/config/media/mimedetect).
  41. By default, only the PHP fileinfo detection engine is enabled.
  42. USAGE
  43. -----
  44. MimeDetect acts as an API, other modules can make usage of it by calling
  45. 'mimedetect_mime' function.
  46. A simple file upload validator is included in a separate module for illustration
  47. purposes, basic functionality and backward compatibility with Drupal 6. It
  48. rejects any file upload which detected MIME type doesn't match the filename
  49. extension.
  50. DRUPAL 6 UPGRADE
  51. ----------------
  52. Drupal 6 filefield module (https://www.drupal.org/project/filefield) had
  53. integration with MimeDetect. This module is now part of the Drupal 7 core, so
  54. the integration with non-core (third-party) modules like MimeDetect was lost.
  55. This functionality is now provided by the "MimeDetect file upload validator"
  56. module, included as a submodule.
  57. RECOMMENDED MODULES
  58. -------------------
  59. * File MIME (https://www.drupal.org/project/filemime):
  60. Provides a way to alter the core MIME type mapping to file name extensions.
  61. Use it to add unrecognized extensions or to alter the MIME associated with
  62. a particular extension. Some known unrecognized extensions by Drupal core
  63. are:
  64. Audio types:
  65. .rmi (audio/midi)
  66. .aidff (audio/x-aiff)
  67. Image types:
  68. .cod (image/cis-cod)
  69. .jfif (image/pipeg)
  70. .cmx (image/x-cmx)
  71. Video types:
  72. .mpa (video/mpeg)
  73. .mpv2 (video/mpeg)
  74. .asr (video/x-ms-asf)
  75. TROUBLESHOOTING
  76. ---------------
  77. * Updating from older versions:
  78. Previous versions of MimeDetect (7.x-1.0 and older) were distributed with a
  79. Magic database file to make FileInfo based MIME detection more consistent
  80. across servers. Due to that different PHP version expect different 'magic'
  81. file format, there were frequently errors on installation and after PHP
  82. version updates, so this database has been removed in favor of the default
  83. magic information available in system server or bundled with PHP fileinfo
  84. extension.
  85. This change affects only the default behaviour; if your website is
  86. configured to use a custom magic, MimeDetect will be still running with it.
  87. For the default behaviour, might be slight differences in MIME type
  88. detection since the magic information is now taken from system or PHP, not
  89. from the old provided magic file. In any case, default behaviour should be
  90. now more accurate.
  91. * File upload validation with unrecognized file name extensions:
  92. Drupal core maps each file extension with a MIME type. Thats the way the
  93. file_get_mimetype() function guesses the MIME type for a given file name.
  94. Some file name extensions are not present on such map or can be mapped with
  95. a different MIME type than the detected by MimeDetect. For example, that's
  96. the case for portable object (".po") files. PO files are plain text files
  97. that contain translation strings. Drupal core returns the generic
  98. 'application/octet-stream' MIME type for them, whereas 'magic' MIME
  99. detection engines (and therefore MimeDetect) usually returns 'text/x-po' as
  100. the detected MIME type.
  101. This mismatch will make file upload validator to block file uploading. The
  102. right way to solve this is by altering the Drupal core file name extension
  103. map, adding the unrecognized MIME types or overriding existing ones. And
  104. that's exactly what the recommended filemime module does, so you will find
  105. this module useful to solve these scenarios.
  106. CONTACT
  107. -------
  108. Current maintainers:
  109. * Manuel Adan (manuel.adan) - https://www.drupal.org/user/516420
  110. CREDITS
  111. -------
  112. Ported to D6 & D7 by:
  113. * Andrew Morton (drewish) - https://www.drupal.org/user/34869
  114. Created by:
  115. * Darrel O'Pry (dopry) - https://www.drupal.org/user/22202