12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- defined('GNUSOCIAL') || die();
- class Attachment_viewAction extends AttachmentAction
- {
- public function showPage(): void
- {
-
-
-
- @ini_set('display_errors', 0);
- if ($this->attachment->isLocal() || $this->attachment->isFetchedRemoteFile()) {
- try {
- $this->filepath = $this->attachment->getFileOrThumbnailPath();
- } catch (Exception $e) {
- $this->clientError(
- _m('Requested local URL for a file that is not stored locally.'),
- 404
- );
- }
- $disposition = 'attachment';
- if (in_array(common_get_mime_media($this->mimetype), ['image', 'video'])) {
- $disposition = 'inline';
- }
- common_send_file($this->filepath, $this->mimetype, $this->filename, $disposition);
- } else {
- common_redirect($this->attachment->getUrl(), 303);
- }
- }
- }
|