Gem Paperclip 和 Carrierwave 哪个更好?

jasl · 2012年03月09日 · 最后由 rubyu2 回复于 2014年05月15日 · 7265 次阅读

我是用 mysql 的,请问这两个 gem 各有什么特点?网上对比的文章好少啊

个人更喜欢 carrierwave,它把文件处理相关的逻辑抽取出来成为独立的文件。设计上更好。

carrierwave 路过。。和 Mongoid 一起用比较方便。

没有仔细研究,提供个排名供参考:https://www.ruby-toolbox.com/categories/rails_file_uploads Paperclip 领先。

我用的是 Carrierwave,因为能用 mongoid。

paperclip 有 thoughtbot 支持,但是我也是很喜欢 carrierwave 把逻辑抽出的设计,不好办啊

不用纠结,两个很像,选一个好了,这不是重点。 我们用的 carrierwave,主要是和又拍云集成的很好。 之前我们用的是 paperclip,迁移到 carrierwave 几乎不费力气。

#4 楼 @jasl paperclip 领先应该是因为这个 gem 出来得比较早

paperclip

I have used CarrierWave and after some hours of frustration I'm switching to Paperclip.

Here are the problems I have seen with CarrierWave:

  • You can't validate file size. There is a wiki article that explains how to do it, but it does not work.
  • Integrity validations do not work when using MiniMagick (very convenient if you are concerned about RAM usage). You can upload a corrupted image file and CarrierWave will throw an error at first, but the next time will swallow it.
  • You can't delete the original file. You can instead resize it, compress, etc. There is a wiki article explaining how to do it, but again it does not work.
  • It depends on external libraries such as RMagick or MiniMagick. Paperclip works directly with the convert command line (ImageMagick). So, if you have problems with Minimagick (I had), you will lose hours diving in Google searches. Both RMagick and Minimagick are abandoned at the time of this writing (I contacted the author of Minimagic, no response).
  • It needs some configuration files. This is seen as an advantage, but I don't like having single configuration files around my project just for one gem. Configuration in the model seems more natural to me. This is a matter of personal taste anyway.
  • If you find some bug and report it, the dev team is really absent and busy. They will tell you to fix bugs yourself. It seems like a personal project that is improved in spare time. For me it's not valid for a professional project with deadlines.

http://stackoverflow.com/questions/7419731/rails-3-paperclip-vs-carrierwave-vs-dragonfly-vs-attachment-fu

@hooopo

  • filesize 可以在反向代理层进行 validate
  • 对 mini_magick 这方面不太清楚,早期读使用 paperclip 的 proj 依赖 rmagic 的也不少貌似
  • 保留原始文件这个我觉得和提倡软删除而不是硬删除一样,保留原始文件虽然不利于空间占用,但也可能会有好处
  • carrierwave 把 uploader 独立天然的 dry 了,而 paperclip 还需要通过 concern 方式手动去做一些
  • 社区维护这方面不太清楚

所以,我觉得是两个完全不同的设计思路,各有优劣,看情况去使用就好,carrierwave 因为有 uploader 类,所以我可以在这个层面对一些内部的东西做 hack,效果也还可以

paperclip rubychina 应该弄个投票。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册