Skip to content

Instantly share code, notes, and snippets.

@sebastiandeutsch
Created January 26, 2011 18:55
Show Gist options
  • Save sebastiandeutsch/797207 to your computer and use it in GitHub Desktop.
Save sebastiandeutsch/797207 to your computer and use it in GitHub Desktop.
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