You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if file content is passed, it tries to get its mime type with finfo
if that mime type is null or 'inconclusive', it falls back to map
In other words, we're forced to read the file contents to use this.
On the other hand, detectMimeTypeFromFile returns the mime type by checking the file contents without requiring the contents to be passed.
My expectation of the function logic would have been:
if contents are passed, guess from contents
otherwise, guess from file (path)
if inconclusive, use map
i.e. in other words $contents would be optional, but it would still check the file.
I guess updating the behaviour now could be considered as a BC break though.
The text was updated successfully, but these errors were encountered:
uuf6429
changed the title
Logic behind detectMimeType is a bit odd
Logic behind detectMimeType is a bit odd (or code be improved)
Sep 28, 2022
uuf6429
changed the title
Logic behind detectMimeType is a bit odd (or code be improved)
Logic behind detectMimeType is a bit odd (or could be improved)
Aug 18, 2024
Current behaviour of
detectMimeType()
:finfo
In other words, we're forced to read the file contents to use this.
On the other hand,
detectMimeTypeFromFile
returns the mime type by checking the file contents without requiring the contents to be passed.My expectation of the function logic would have been:
i.e. in other words
$contents
would be optional, but it would still check the file.https://github.com/thephpleague/mime-type-detection/blob/main/src/FinfoMimeTypeDetector.php#L54
I guess updating the behaviour now could be considered as a BC break though.
The text was updated successfully, but these errors were encountered: