X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7f3ed5e22e01b9cc8efe9ebfc79a2591b37b14d7..4259263d270a5e377009d20835a463551c708d82:/apps/workbench/app/helpers/collections_helper.rb diff --git a/apps/workbench/app/helpers/collections_helper.rb b/apps/workbench/app/helpers/collections_helper.rb index 23a440ad1e..25f2cb53e6 100644 --- a/apps/workbench/app/helpers/collections_helper.rb +++ b/apps/workbench/app/helpers/collections_helper.rb @@ -53,4 +53,21 @@ module CollectionsHelper f0 += '/' if not f0.empty? file_path = "#{f0}#{file[1]}" end + + ## + # Check if collection preview is allowed for the given filename with extension + # + def preview_allowed_for file_name + file_type = MIME::Types.type_for(file_name).first + if file_type.nil? + false + elsif (file_type.raw_media_type == "text") || (file_type.raw_media_type == "image") + true + elsif (file_type.raw_media_type == "application") && + (Rails.configuration.application_mimetypes_with_view_icon.include? (file_type.sub_type)) + true + else + false + end + end end