OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/uploaders/file_uploader.rb

31 lines
510 B

module FileUploader
def self.included(base)
base.extend ClassMethods
end
def local_file
file.to_file
end
def download_url
file.is_path? ? file.path : file.url
end
def cache_dir
self.class.cache_dir
end
module ClassMethods
def cache_dir
@cache_dir ||= begin
tmp = Tempfile.new 'op_uploaded_files'
path = Pathname(tmp)
tmp.delete # delete temp file
path.mkdir # create temp directory
path.to_s
end
end
end
end