{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/flysystem/issues/571","labels_url":"https://api.github.com/repos/thephpleague/flysystem/issues/571/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/flysystem/issues/571/comments","events_url":"https://api.github.com/repos/thephpleague/flysystem/issues/571/events","html_url":"https://github.com/thephpleague/flysystem/issues/571","id":118405789,"number":571,"title":"MIME type extension detection fallback not invoked when \"application/x-empty\" detected","user":{"login":"ivarb","id":849042,"avatar_url":"https://avatars.githubusercontent.com/u/849042?v=3","gravatar_id":"","url":"https://api.github.com/users/ivarb","html_url":"https://github.com/ivarb","followers_url":"https://api.github.com/users/ivarb/followers","following_url":"https://api.github.com/users/ivarb/following{/other_user}","gists_url":"https://api.github.com/users/ivarb/gists{/gist_id}","starred_url":"https://api.github.com/users/ivarb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivarb/subscriptions","organizations_url":"https://api.github.com/users/ivarb/orgs","repos_url":"https://api.github.com/users/ivarb/repos","events_url":"https://api.github.com/users/ivarb/events{/privacy}","received_events_url":"https://api.github.com/users/ivarb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-23T15:31:31Z","updated_at":"2015-12-24T08:47:20Z","closed_at":"2015-12-18T21:52:27Z","body":"Hi,\r\n\r\nI'm using a Local FlySystem adapter setup with the Memory cache adapter plugin enabled. \r\nCalling `FileSystem::getMimeType()` often returns `application/x-empty` for files where the proper mime type should be detectable based on the file's extension.\r\n\r\nThis is triggered by the Memory plugin, that first calls the `Util::guessMimeType()` method with boolean `false` passed as the value for content (because the Memory adapter does not read the file's content.). See:\r\nhttps://github.com/thephpleague/flysystem-cached-adapter/blob/master/src/Storage/AbstractCache.php#L240-L244\r\n\r\nThen, the `League\\Flysystem\\Util` component first tries to detect the mime type based on the content passed (no `empty()` check is applied to `$content`). See https://github.com/thephpleague/flysystem/blob/master/src/Util.php#L162-L165\r\n\r\nThe `Leage\\FlySystem\\Util\\MimeType` component uses `Finfo::buffer()`, which always seems to return `application/x-empty` when `false` (or an empty string) is passed to it.\r\nSee https://github.com/thephpleague/flysystem/blob/master/src/Util/MimeType.php#L25-L28\r\n\r\nIt might be a good idea to detect `application/x-empty` in https://github.com/thephpleague/flysystem/blob/master/src/Util.php#L164 and to fallback to extension based detection instead.\r\n\r\nCLI example PHP 5.6:\r\n```\r\nphp > echo (new Finfo(FILEINFO_MIME_TYPE))->buffer('');\r\napplication/x-empty\r\n\r\n$ php -v\r\nPHP 5.6.13-1+deb.sury.org~trusty+3 (cli)\r\nCopyright (c) 1997-2015 The PHP Group\r\nZend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies\r\n    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies\r\n```\r\n\r\nThanks in advance for the support!"},"comment":{"url":"https://api.github.com/repos/thephpleague/flysystem/issues/comments/167070155","html_url":"https://github.com/thephpleague/flysystem/issues/571#issuecomment-167070155","issue_url":"https://api.github.com/repos/thephpleague/flysystem/issues/571","id":167070155,"user":{"login":"frankdejonge","id":534693,"avatar_url":"https://avatars.githubusercontent.com/u/534693?v=3","gravatar_id":"","url":"https://api.github.com/users/frankdejonge","html_url":"https://github.com/frankdejonge","followers_url":"https://api.github.com/users/frankdejonge/followers","following_url":"https://api.github.com/users/frankdejonge/following{/other_user}","gists_url":"https://api.github.com/users/frankdejonge/gists{/gist_id}","starred_url":"https://api.github.com/users/frankdejonge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankdejonge/subscriptions","organizations_url":"https://api.github.com/users/frankdejonge/orgs","repos_url":"https://api.github.com/users/frankdejonge/repos","events_url":"https://api.github.com/users/frankdejonge/events{/privacy}","received_events_url":"https://api.github.com/users/frankdejonge/received_events","type":"User","site_admin":false},"created_at":"2015-12-24T08:47:20Z","updated_at":"2015-12-24T08:47:20Z","body":"@ivarb welcome :+1: "}}