Feature #60019

Create utility function to get the file mimetype depending on available php modules

Added by Sascha Egerer about 1 year ago. Updated 5 months ago.

Status:Resolved Start date:2014-07-01
Priority:Should have Due date:
Assigned To:- % Done:

100%

Category:File Abstraction Layer (FAL) Spent time: -
Target version:next-patchlevel
PHP Version:5.5 Sprint Focus:On Location Sprint
Complexity:

Description

TYPO3 does currently use finfo_file to get the mime type of a file. This does only work if the finfo module is loaded in PHP.
dkd is currently working with Microsoft to get TYPO3 working in the Microsoft Azure Web Gallery and there is no finfo module installed by default.

To get this code a little bit more portable there should be a wrapper function that checks if the finfo exsists and if not use mime_content_type.


Related issues

duplicated by Core - Task #46777: Improve behaviour when mime type detection is missing Closed 2013-03-29
precedes Core - Bug #64929: Fix filesize Unittest on windows with CRLF Resolved 2015-02-08

Associated revisions

Revision e372399b
Added by Sascha Egerer 6 months ago

[FEATURE] Add SplFileInfo implementation to get file mimeType

\TYPO3\CMS\Core\Type\File\FileInfo provides a new method
getMimeType() to get the MIME type of a file, e.g. text/html.

Custom implementations to determine the MIME type can be added
with the hook:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuessers']

The FAL LocalDriver also uses this new API.

Resolves: #60019
References: #46777
Releases: master
Change-Id: Ia2fa95d2ef6452f8022e33f1b1d2a9336f3e0303
Reviewed-on: http://review.typo3.org/31256
Reviewed-by: Mathias Schreiber <>
Tested-by: Mathias Schreiber <>
Reviewed-by: Frans Saris <>
Reviewed-by: Helmut Hummel <>
Reviewed-by: Stefan Neufeind <>
Tested-by: Stefan Neufeind <>
Tested-by: Steffen Müller <>
Reviewed-by: Steffen Müller <>

History

#1 Updated by Gerrit Code Review about 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/31256

#2 Updated by Gerrit Code Review about 1 year ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/31256

#3 Updated by Gerrit Code Review about 1 year ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#4 Updated by Ingo Schmitt 7 months ago

  • Category set to File Abstraction Layer (FAL)

#5 Updated by Sascha Egerer 6 months ago

  • Target version set to next-patchlevel
  • Sprint Focus set to On Location Sprint

#6 Updated by Gerrit Code Review 6 months ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#7 Updated by Gerrit Code Review 6 months ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#8 Updated by Gerrit Code Review 6 months ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#9 Updated by Gerrit Code Review 6 months ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#10 Updated by Gerrit Code Review 6 months ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#11 Updated by Gerrit Code Review 6 months ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/31256

#12 Updated by Anonymous 6 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#13 Updated by Stephan Großberndt 6 months ago

  • Tracker changed from Bug to Feature

#14 Updated by Beltran Rueda 5 months ago

I could reproduce the following issue on Windows using 7.1.0 version:

PHP Fatal error:  Class 'finfo' not found in ...\typo3\sysext\core\Classes\Type\File\FileInfo.php on line 33

Replacing the following in the FileInfo.php file fixes the issue. Could you confirm this fix is correct?

if (!function_exists('finfo_file')) {

with:

if (function_exists('finfo_file')) {

#15 Updated by Wouter Wolters 5 months ago

Hi, this has been fixed meanwhile with https://review.typo3.org/#/c/37205/

Also available in: Atom PDF