123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class Attachment_viewAction extends AttachmentAction
- {
- public function showPage()
- {
-
- $filepath = $this->attachment->getFileOrThumbnailPath();
- $filesize = $this->attachment->getFileOrThumbnailSize();
- $mimetype = $this->attachment->getFileOrThumbnailMimetype();
- if (empty($filepath)) {
- $this->clientError(_('No such attachment'), 404);
- }
- $filename = MediaFile::getDisplayName($this->attachment);
-
-
-
- @ini_set('display_errors', 0);
- header("Content-Description: File Transfer");
- header("Content-Type: {$mimetype}");
- if (in_array(common_get_mime_media($mimetype), ['image', 'video'])) {
- header("Content-Disposition: inline; filename=\"{$filename}\"");
- } else {
- header("Content-Disposition: attachment; filename=\"{$filename}\"");
- }
- header('Expires: 0');
- header('Content-Transfer-Encoding: binary');
- AttachmentAction::sendFile($filepath, $filesize);
- }
- }
|