Description
Hi,
First of all, thank you very much for maintaining Flysystem!
I've been using Flysystem for a long time in various projects, and it's been incredibly helpful. 🙏
Currently, I'm working on developing a Flysystem adapter for Nextcloud, using its WebDAV interface.
While running the adapter test suite (league/flysystem-adapter-test-utilities
), I noticed that the fetching_unknown_mime_type_of_a_file
test assumes that fetching the MIME type for an .md5
file should throw an UnableToRetrieveMetadata
exception.
However, in practice, some servers (like Nextcloud WebDAV) return a valid MIME type like application/octet-stream
for such files.
Because of this, the test fails even though the adapter behaves correctly according to Flysystem's expectations.
Test:
public function fetching_unknown_mime_type_of_a_file(): void
{
$this->givenWeHaveAnExistingFile(
'unknown-mime-type.md5',
file_get_contents(__DIR__ . '/test_files/unknown-mime-type.md5')
);
$this->expectException(UnableToRetrieveMetadata::class);
$this->runScenario(function () {
$this->adapter()->mimeType('unknown-mime-type.md5');
});
}
- As I can see, returning
application/octet-stream
is valid behavior when the actual MIME type is unknown. - According to the IETF MIME standards (RFC 2046),
application/octet-stream
is the default MIME type when the actual content type is unknown or cannot be determined. - Given that, should
application/octet-stream
still trigger anUnableToRetrieveMetadata
exception in Flysystem? - Or should it be considered a valid MIME type and accepted as a fallback, without throwing an exception?
Question:
- Is there any approach you would suggest for handling this case (should this be then handled as Uknown mime type)?
Thanks again for your time!