2010-06-03 20:20:53 +00:00
|
|
|
require 'carrierwave'
|
2010-05-11 21:38:52 +00:00
|
|
|
|
|
|
|
module CarrierWave
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
class SanitizedFile
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
# FIXME (Did) CarrierWave speaks mime type now
|
2011-06-10 23:18:34 +00:00
|
|
|
def content_type_with_file_mime_type
|
|
|
|
content_type_without_file_mime_type || File.mime_type?(original_filename)
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-06-10 23:18:34 +00:00
|
|
|
alias_method_chain :content_type, :file_mime_type
|
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-04-07 09:53:07 +00:00
|
|
|
module Uploader
|
|
|
|
|
|
|
|
class Base
|
|
|
|
|
|
|
|
def build_store_dir(*args)
|
|
|
|
default_dir = self.class.store_dir
|
|
|
|
|
|
|
|
if default_dir.blank? || default_dir == 'uploads'
|
2011-04-24 23:21:38 +00:00
|
|
|
File.join(args.map(&:to_s))
|
2011-04-07 09:53:07 +00:00
|
|
|
else
|
2011-04-24 23:21:38 +00:00
|
|
|
File.join([default_dir] + args.map(&:to_s))
|
2011-04-07 09:53:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-05-11 21:38:52 +00:00
|
|
|
end
|