Skip to content

Commit

Permalink
feat(files): add mime icon endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jan 10, 2025
1 parent 045a990 commit 6d94040
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions core/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\Attribute\OpenAPI;
use OCP\AppFramework\Http\Attribute\PublicPage;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\RedirectResponse;
Expand Down Expand Up @@ -183,4 +184,24 @@ private function fetchPreview(
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
}

/**
* Get a preview by mime
*
* @return RedirectResponse<Http::STATUS_SEE_OTHER, array{}>
*
* 303: The mime icon url
*/
#[NoCSRFRequired]
#[PublicPage]
#[FrontpageRoute(verb: 'GET', url: '/core/mimeicon')]
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)]
public function getMimeIconUrl(string $mime = 'application/octet-stream') {
$url = $this->mimeIconProvider->getMimeIconUrl($mime);
if ($url === null) {
$url = $this->mimeIconProvider->getMimeIconUrl('application/octet-stream');
}

return new RedirectResponse($url);
}
}

0 comments on commit 6d94040

Please sign in to comment.