beginnings of new API

This commit is contained in:
Kyle Drake 2014-04-06 23:57:35 -04:00
parent 138169ce6b
commit 3871c4d0fa
3 changed files with 137 additions and 32 deletions

View file

@ -125,6 +125,14 @@ class Site < Sequel::Model
}
end
def self.valid_file_type?(uploaded_file)
mime_type = Magic.guess_file_mime_type uploaded_file[:tempfile].path
return true if (Site::VALID_MIME_TYPES.include?(mime_type) || mime_type =~ /text/) &&
Site::VALID_EXTENSIONS.include?(File.extname(uploaded_file[:filename]).sub(/^./, '').downcase)
false
end
def store_file(filename, uploaded)
FileUtils.mv uploaded.path, file_path(filename)
File.chmod(0640, file_path(filename))