From 2b1d44e9b0221a347c1a406c67d6c7dfff7f5380 Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Tue, 7 Jan 2025 16:48:31 -0500 Subject: [PATCH] feat: update mime extension mappings Signed-off-by: Elizabeth Danzberger --- lib/Conversion/ConversionProvider.php | 40 +++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/Conversion/ConversionProvider.php b/lib/Conversion/ConversionProvider.php index 5b305d5df7..3d566b186b 100644 --- a/lib/Conversion/ConversionProvider.php +++ b/lib/Conversion/ConversionProvider.php @@ -18,22 +18,22 @@ class ConversionProvider implements IConversionProvider { public const MIME_EXTENSION_MAP = [ 'application/word' => 'doc', - 'application/vnd.ms-powerpoint' => 'ppt', - 'application/vnd.visio' => 'vsd', - 'application/vnd.ms-excel' => 'xls', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', - 'application/vnd.oasis.opendocument.text' => 'odt', - 'application/vnd.oasis.opendocument.presentation' => 'odp', - 'application/vnd.oasis.opendocument.spreadsheet' => 'ods', - 'application/vnd.oasis.opendocument.graphics' => 'odg', - 'application/vnd.oasis.opendocument.text-template' => 'ott', + + 'application/vnd.ms-powerpoint' => 'ppt', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', + 'application/vnd.oasis.opendocument.presentation' => 'odp', 'application/vnd.oasis.opendocument.presentation-template' => 'otp', + + 'application/vnd.ms-excel' => 'xls', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', + 'application/vnd.oasis.opendocument.spreadsheet' => 'ods', 'application/vnd.oasis.opendocument.spreadsheet-template' => 'ots', + + 'application/vnd.visio' => 'vsd', + 'application/vnd.oasis.opendocument.graphics' => 'odg', 'application/vnd.oasis.opendocument.graphics-template' => 'otg', 'application/pdf' => 'pdf', @@ -49,13 +49,19 @@ public function getName(): string { } public function getSupportedMimeTypes(): array { - $textToPdf = new ConversionMimeTuple('application/vnd.oasis.opendocument.text', [ - 'application/pdf', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - ] - ); + $supportedMimeTypes = []; + + foreach (self::MIME_EXTENSION_MAP as $mimeType => $extension) { + if ($mimeType === 'application/pdf') { + continue; + } + + $supportedMimeTypes[] = new ConversionMimeTuple($mimeType, [ + 'application/pdf' + ]); + } - return [$textToPdf]; + return $supportedMimeTypes; } public function convertFile(File $file, string $targetMimeType): mixed {