{"action":"created","issue":{"url":"https://api.github.com/repos/daokoder/dao-modules/issues/48","labels_url":"https://api.github.com/repos/daokoder/dao-modules/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/daokoder/dao-modules/issues/48/comments","events_url":"https://api.github.com/repos/daokoder/dao-modules/issues/48/events","html_url":"https://github.com/daokoder/dao-modules/issues/48","id":93255623,"number":48,"title":"web.mime - enhancements","user":{"login":"dumblob","id":2451044,"avatar_url":"https://avatars.githubusercontent.com/u/2451044?v=3","gravatar_id":"","url":"https://api.github.com/users/dumblob","html_url":"https://github.com/dumblob","followers_url":"https://api.github.com/users/dumblob/followers","following_url":"https://api.github.com/users/dumblob/following{/other_user}","gists_url":"https://api.github.com/users/dumblob/gists{/gist_id}","starred_url":"https://api.github.com/users/dumblob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dumblob/subscriptions","organizations_url":"https://api.github.com/users/dumblob/orgs","repos_url":"https://api.github.com/users/dumblob/repos","events_url":"https://api.github.com/users/dumblob/events{/privacy}","received_events_url":"https://api.github.com/users/dumblob/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/daokoder/dao-modules/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-07-06T11:25:58Z","updated_at":"2015-07-07T20:21:57Z","closed_at":null,"body":"Currently only the method `identify(target: string) => list<string>` is available, but a method with reverse semantics `extof(mime: string) => list<string>` (not sure if the relationship is really N:M, but if only 1:M, then this should be correct: `extof(mime: string) => string`) returning feasible extensions would be also convenient.\r\n\r\nAnother enhancement would be (based on how the [Go module `mime`](https://golang.org/pkg/mime/) handles it) addition of reading `/etc/mime.types` `/etc/apache2/mime.types` `/etc/apache/mime.types` (if available on unix systems) and from Windows registry on Microsoft systems. This might also require addition of yet another method - `refresh()` - running `stat()` and updating the mapping if some change occured.\r\n\r\nAnd finally, the biggest improvement would be to add support for \"real\" MIME identification based on https://github.com/file/file/ (compiled statically into the module including the magic DB which has about 408KB in plain text) and extending the interface to become something like `identify(target: string|stream|Entry|File, magic = false) => list<string>` (`Entry` is not an issue, because a directory has usually also MIME type - see http://stackoverflow.com/a/26211796).\r\n\r\nBtw I didn't use file extensions for about 6 years - I always use the magic database and working with files according to their content. It's a very safe way of treating files."},"comment":{"url":"https://api.github.com/repos/daokoder/dao-modules/issues/comments/119324989","html_url":"https://github.com/daokoder/dao-modules/issues/48#issuecomment-119324989","issue_url":"https://api.github.com/repos/daokoder/dao-modules/issues/48","id":119324989,"user":{"login":"dumblob","id":2451044,"avatar_url":"https://avatars.githubusercontent.com/u/2451044?v=3","gravatar_id":"","url":"https://api.github.com/users/dumblob","html_url":"https://github.com/dumblob","followers_url":"https://api.github.com/users/dumblob/followers","following_url":"https://api.github.com/users/dumblob/following{/other_user}","gists_url":"https://api.github.com/users/dumblob/gists{/gist_id}","starred_url":"https://api.github.com/users/dumblob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dumblob/subscriptions","organizations_url":"https://api.github.com/users/dumblob/orgs","repos_url":"https://api.github.com/users/dumblob/repos","events_url":"https://api.github.com/users/dumblob/events{/privacy}","received_events_url":"https://api.github.com/users/dumblob/received_events","type":"User","site_admin":false},"created_at":"2015-07-07T20:21:57Z","updated_at":"2015-07-07T20:21:57Z","body":">All that is either too unlikely in case of Dao or too abstract.\r\n\r\nI've deliberately mentioned only real use cases.\r\n\r\n>I don't see an immediate need to deal with yet another set of mappings. I don't see a task at hand which that functionality would solve, so I'm just lazy to do that.\r\n\r\nLet's make up one :) Imagine, you're an organizer of a small programming contest and you're gathering the short codes written in any programming language using an html submit form. Now, to run them on Windows, you need to save the form content to files with appropriate extensions after examining them for their MIME type using magic library.\r\n\r\n>Perhaps there is a suitable magic-library which can be wrapped with little efforts?\r\n\r\nNot to my knowledge - everything I found is using the original `libmagic` from https://github.com/file/file/ . The binding itself [shouldn't be so difficult](https://github.com/vimeo/go-magic/tree/master/magic)."}}