-
-
Save sebastiandeutsch/797207 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AttachmentUploader < CarrierWave::Uploader::Base | |
include CarrierWave::MiniMagick | |
storage :s3 | |
def s3_headers | |
content_type = {"Content-Type" => "application/octet-stream"} | |
if self.file.filename.match(/(\.jpg)|(\.jpeg)/) | |
content_type = {"Content-Type" => "image/jpeg"} | |
end | |
if self.file.filename.match(/\.png/) | |
content_type = {"Content-Type" => "image/png"} | |
end | |
if self.file.filename.match(/\.pdf/) | |
content_type = {"Content-Type" => "application/pdf"} | |
end | |
return content_type | |
end | |
def store_dir | |
['system', 'attachments', model.id].join('/') | |
end | |
def extension_white_list | |
%w(zip pdf ps dvi doc docx ppt pptx xls xlsx jpg jpeg gif png rtf) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment