Open marc-mabe opened 2 years ago
Yup, this is causing us some grief as well. Specifically the lack of
if fallback detectMimeTypeFromPath returns null use the previous detected mime type
We're getting a valid text/plain
from detectMimeTypeFromFile()
, but then it falls back to detectMimeTypeFromPath()
which returns null and results in an exception being thrown.
I've raised https://github.com/thephpleague/flysystem/pull/1710 to handle that part of this issue.
Bug Report
Summary
FinfoMimeTypeDetector
has definedINCONCLUSIVE_MIME_TYPES
which containstext/plain
. This will be used ondetectMimeType
and if the detected type in this list it falls back todetectMimeTypeFromPath
.On the other hand the local file adapter uses
detectMimeTypeFromFile
which does not check forINCONCLUSIVE_MIME_TYPES
at all.How to reproduce
Create a tsv file (tab separated values)
Use local file adapter
mimeType()
(which usedFinfoMimeTypeDetector::detectMimeTypeFromFile
)you will get
text/plain
Create the same tsv file in memory adapter
Use local file adapter
mimeType()
(which usedFinfoMimeTypeDetector::detectMimeType
)you will get
text/tab-separated-values
Idea how to fix
INCONCLUSIVE_MIME_TYPES
should be used in all cases a path exists and fall back todetectMimeTypeFromPath
detectMimeTypeFromPath
returnsnull
use the previous detected mime typeSomething like this: