From 174337fd032eda380fd671dfdcd3f6d773ac2ad3 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Tue, 4 Apr 2023 12:26:07 -0400 Subject: [PATCH] HotFix: Patching Marcel MimeType sniffing Note: This does not included tests, which is something that #777 also did not. However, we have verified the behavior. Reading the [documentation for the Marcel gem][1], it requires a file handle (e.g. `File.new` or `File.open`) instead of a String. When given a `String` for `::Marcel::MimeType.for` the returned value is `application/octet-stream`. Related to: - https://github.com/samvera-labs/bulkrax/issues/777 [1]: https://github.com/rails/marcel --- app/models/concerns/bulkrax/importer_exporter_behavior.rb | 2 +- app/parsers/bulkrax/application_parser.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/concerns/bulkrax/importer_exporter_behavior.rb b/app/models/concerns/bulkrax/importer_exporter_behavior.rb index 678a7e7f..f333db5d 100644 --- a/app/models/concerns/bulkrax/importer_exporter_behavior.rb +++ b/app/models/concerns/bulkrax/importer_exporter_behavior.rb @@ -51,7 +51,7 @@ def file? # Is this a zip file? def zip? - parser_fields&.[]('import_file_path') && ::Marcel::MimeType.for(parser_fields['import_file_path']).include?('application/zip') + parser_fields&.[]('import_file_path') && ::Marcel::MimeType.for(File.new(parser_fields['import_file_path'])).include?('application/zip') end end end diff --git a/app/parsers/bulkrax/application_parser.rb b/app/parsers/bulkrax/application_parser.rb index bb8c551d..f00df771 100644 --- a/app/parsers/bulkrax/application_parser.rb +++ b/app/parsers/bulkrax/application_parser.rb @@ -365,7 +365,7 @@ def file? # Is this a zip file? def zip? - parser_fields&.[]('import_file_path') && ::Marcel::MimeType.for(parser_fields['import_file_path']).include?('application/zip') + parser_fields&.[]('import_file_path') && ::Marcel::MimeType.for(File.new(parser_fields['import_file_path'])).include?('application/zip') end # Path for the import