diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-11 12:14:32 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-11 12:14:32 +0400 |
commit | ab19196391f6383cd11a9f2f748bc2a90287fcc4 (patch) | |
tree | 837e7a3e761acf4d0f004fb4f387c7163f4e8cd4 | |
parent | 2d83e43db0163028fddd54095a7f7260b3e5cc65 (diff) |
fix attachment uploader for aws
-rw-r--r-- | app/uploaders/attachment_uploader.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/uploaders/attachment_uploader.rb b/app/uploaders/attachment_uploader.rb index 391731d9470..3dbf2860bd4 100644 --- a/app/uploaders/attachment_uploader.rb +++ b/app/uploaders/attachment_uploader.rb @@ -8,6 +8,15 @@ class AttachmentUploader < CarrierWave::Uploader::Base end def image? - %w(png jpg jpeg).include?(file.extension) + img_ext = %w(png jpg jpeg) + if file.respond_to?(:extension) + img_ext.include?(file.extension) + else + # Not all CarrierWave storages respond to :extension + ext = file.path.split('.').last + img_ext.include?(ext) + end + rescue + false end end |