mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
31 lines
594 B
Ruby
31 lines
594 B
Ruby
class FileUtility
|
|
|
|
@@exts_document = %w(.docx .doc .odt .rtf .txt .html .htm .mht .pdf .djvu .fb2 .epub .xps)
|
|
|
|
@@exts_spreadsheet = %w(.xls .xlsx .ods .csv)
|
|
|
|
@@exts_presentation = %w(.pps .ppsx .ppt .pptx .odp)
|
|
|
|
class << self
|
|
|
|
def get_file_type(file_name)
|
|
ext = File.extname(file_name)
|
|
|
|
if @@exts_document.include? ext
|
|
return 'text'
|
|
end
|
|
|
|
if @@exts_spreadsheet.include? ext
|
|
return 'spreadsheet'
|
|
end
|
|
|
|
if @@exts_presentation.include? ext
|
|
return 'presentation'
|
|
end
|
|
|
|
'text'
|
|
end
|
|
|
|
end
|
|
|
|
end |