From 67856c2f13cd64bbd66146ebc02bd55bfd0fb2a8 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 9 Sep 2022 15:54:13 +0200 Subject: [PATCH] fix(upload.custom-types): army has a custom format for crypted zip. not recognized as an application/octet-stream by the browser. html5[accpet] attributes allows to use extensions. So we allow this extension --- app/components/attachment/edit_component.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/components/attachment/edit_component.rb b/app/components/attachment/edit_component.rb index 887443962..38a98bda3 100644 --- a/app/components/attachment/edit_component.rb +++ b/app/components/attachment/edit_component.rb @@ -53,7 +53,7 @@ class Attachment::EditComponent < ApplicationComponent data: { auto_attach_url: helpers.auto_attach_url(form.object) }.merge(has_file_size_validator? ? { max_file_size: max_file_size } : {}) - }.merge(has_content_type_validator? ? { accept: content_type_validator.options[:in].join(', ') } : {}) + }.merge(has_content_type_validator? ? { accept: accept_content_type } : {}) end def input_id(given_id) @@ -100,6 +100,14 @@ class Attachment::EditComponent < ApplicationComponent .find { |validator| validator.class == ActiveStorageValidations::ContentTypeValidator } end + def accept_content_type + list = content_type_validator.options[:in] + if list.include?("application/octet-stream") + list.push(".acidcsa") + end + list.join(', ') + end + def has_content_type_validator? !content_type_validator.nil? end