From cfb69dfa28af542261562e0d5c7ba962f2419e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Lindo?= Date: Tue, 28 Nov 2023 09:09:36 +0000 Subject: [PATCH] Environment variable to disable Tika AutoDetectParser characters limit --- .../transformers/ToolkitStructure2ViewerStructure.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java b/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java index 8c1ade52..435b20a7 100644 --- a/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java +++ b/src/main/java/com/databasepreservation/common/transformers/ToolkitStructure2ViewerStructure.java @@ -922,7 +922,14 @@ private static void detectMimeType(ViewerRow row, ViewerCell cell, String databa AutoDetectParser parser = new AutoDetectParser(); Metadata metadata = new Metadata(); - parser.parse(inputStream, new BodyContentHandler(), metadata, new ParseContext()); + Boolean autoDetectParserNoLimit = ViewerFactory.getEnvBoolean("AUTO_DETECT_PARSER_NO_LIMIT", false); + + if (autoDetectParserNoLimit) { + parser.parse(inputStream, new BodyContentHandler(-1), metadata, new ParseContext()); + } else { + parser.parse(inputStream, new BodyContentHandler(), metadata, new ParseContext()); + } + mimeType = metadata.get("Content-Type"); fileExtension = MimeTypes.getDefaultMimeTypes().forName(mimeType).getExtension();