Commit ab19196391f6383cd11a9f2f748bc2a90287fcc4
1 parent
2d83e43d
Exists in
master
and in
4 other branches
fix attachment uploader for aws
Showing
1 changed file
with
10 additions
and
1 deletions
Show diff stats
app/uploaders/attachment_uploader.rb
| @@ -8,6 +8,15 @@ class AttachmentUploader < CarrierWave::Uploader::Base | @@ -8,6 +8,15 @@ class AttachmentUploader < CarrierWave::Uploader::Base | ||
| 8 | end | 8 | end |
| 9 | 9 | ||
| 10 | def image? | 10 | def image? |
| 11 | - %w(png jpg jpeg).include?(file.extension) | 11 | + img_ext = %w(png jpg jpeg) |
| 12 | + if file.respond_to?(:extension) | ||
| 13 | + img_ext.include?(file.extension) | ||
| 14 | + else | ||
| 15 | + # Not all CarrierWave storages respond to :extension | ||
| 16 | + ext = file.path.split('.').last | ||
| 17 | + img_ext.include?(ext) | ||
| 18 | + end | ||
| 19 | + rescue | ||
| 20 | + false | ||
| 12 | end | 21 | end |
| 13 | end | 22 | end |