Skip to content

Commit

Permalink
feat: update mime extension mappings
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <[email protected]>
  • Loading branch information
elzody committed Jan 7, 2025
1 parent 7a0be7d commit 2b1d44e
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions lib/Conversion/ConversionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
class ConversionProvider implements IConversionProvider {

Check failure on line 18 in lib/Conversion/ConversionProvider.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedClass

lib/Conversion/ConversionProvider.php:18:37: UndefinedClass: Class, interface or enum named OCP\Conversion\IConversionProvider does not exist (see https://psalm.dev/019)
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',
Expand All @@ -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 {
Expand Down

0 comments on commit 2b1d44e

Please sign in to comment.