schovi / baked_file_system

Virtual File System for Crystal language. Embedding your assets into final binary.
MIT License
177 stars 18 forks source link

Remove BakedFile#mime_type #22

Closed straight-shoota closed 5 years ago

straight-shoota commented 6 years ago

Closes #17

straight-shoota commented 6 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.

schovi commented 6 years ago

@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?

straight-shoota commented 6 years ago

Let's wait for https://github.com/crystal-lang/crystal/pull/5765. Should hopefully go in the next release.

straight-shoota commented 5 years ago

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.

schovi commented 5 years ago

@straight-shoota awesome 👍