Closed straight-shoota closed 5 years ago
MIME type resolution should not need to be implemented multiple times but in a generic, reusable way. That's why this shouldn't be included in this shard.
There is an issue to bring a MIME registry to Crystal's stdlib and I've been working on that, but it's not ready yet. There are some shards available with a MIME registry, they can be used to resolve the MIME type at runtime. Depending on a system command at compile time is not a great idea because this would mean you need a properly configured registry on the build system if you don't want to face MIME type issues at runtime. That's just impractical. Shelling out to use a system tool is also not optimal, this should also be handled inside crystal.
@straight-shoota Thanks for an explanation. Can you add an example of working shard to readme? Or can we wait with this PR until it will be available directly in stdlib?
Let's wait for https://github.com/crystal-lang/crystal/pull/5765. Should hopefully go in the next release.
The MIME registry was finally released in Crystal 0.27.1, so this PR can now be merged.
Instead of baked_file.mime_type
, the mime type can now be queried as MIME.from_filename(baked_file.path)
.
See stdlib API docs for more details.
@straight-shoota awesome 👍
Closes #17