filestack / filestack-ruby

Official Ruby SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
https://www.filestack.com
Apache License 2.0
34 stars 27 forks source link

Migrate to marcel instead of mimemagic #80

Closed keymastervn closed 3 years ago

keymastervn commented 3 years ago

The using of mimemagic requires to install Freedesktop.org 's shared-mime-info dependency which is not a no brainer solution. My proposal is changing filestack-ruby from using mimemagic to marcel as a dependency. https://github.com/rails/marcel/releases/tag/v1.0.0

The concern when switching is that mimemagic can broadly support more mime-types than marcel. Should we add more tests to cover supported mimes instead of just image/jpeg?

gabifija commented 3 years ago

@keymastervn Thank you for sharing the idea. I'll take a look on that asap, because as you notice I have to update ruby version to use this gem and add some tests.

PhilCoggins commented 3 years ago

+1 for getting this changed. Activestorage replaced mimemagic with mini_magic several weeks ago in https://github.com/rails/rails/commit/62ac25a3648c8d54c54107554347ea99a4766be2#diff-eec2338fdef55a927e74bdde44f4cd18b6717916113089c3279dee8e790c632f.

With the current mimemagic dependency, filestack-ruby is an extremely large dependency, this is after the gem is required in my Rails application:

filestack: 67.1914 MiB
    filestack/models/filelink: 67.1875 MiB (Also required by: filestack/models/filestack_av)
      filestack/utils/utils: 66.418 MiB (Also required by: filestack/models/filestack_av, filestack/mixins/filestack_common, and 3 others)
        mimemagic: 66.418 MiB (Also required by: filestack/utils/multipart_upload_utils, filestack/mixins/filestack_common)

Compared to rails/all: 57.75 MiB, filestack-ruby has a larger footprint than rails itself!

keymastervn commented 3 years ago

Furthermore, I'd be happy to change the implementation from marcel to mini_mime (which marcel is built upon) if we need more performance over community support

This couldn't be backported to ruby 2.1 and lowers (EOL), I think it's time to bump to 3.0, we can still maintain 2.9 on critical bugs or security issues for some periods of time.

gabifija commented 3 years ago

@PhilCoggins @keymastervn I've replaced mimemagic with mini_mime. Let me know if all good now.