Loading ArticleImageDataHandler.inc.php +1 −12 Original line number Diff line number Diff line Loading @@ -43,18 +43,7 @@ class ArticleImageDataHandler extends ArticleHandler ->formatFilename($file->getData('path'), $file->getLocalizedData('path')); $pathInfo = pathinfo($filename); $imagePath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $pathInfo['filename'] . DIRECTORY_SEPARATOR . $imgName; $mimetype = 'application/octet-stream'; $filesize = $this->fs->fileSize($imagePath); $encodedFilename = urlencode($imgName); header("Content-Type: $mimetype"); header("Content-Length: $filesize"); header('Accept-Ranges: none'); header('Content-Disposition: attachment' . ";filename=\"$encodedFilename\";filename*=UTF-8''$encodedFilename"); header('Cache-Control: private'); // Workarounds for IE weirdness header('Pragma: public'); fpassthru($this->fs->readStream($imagePath)); exit(); ImageUtils::downloadImage($this->fs, $imagePath, $imgName); } return NULL; Loading BookImageDataHandler.inc.php +1 −12 Original line number Diff line number Diff line Loading @@ -49,18 +49,7 @@ class BookImageDataHandler extends CatalogBookHandler $pathInfo = pathinfo($publicationFile->getData('path')); $imagePath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $pathInfo['filename'] . DIRECTORY_SEPARATOR . $imgName; $mimetype = $file->mimetype ?? 'application/octet-stream'; $filesize = $this->fs->fileSize($imagePath); $encodedFilename = urlencode($imgName); header("Content-Type: {$mimetype}"); header("Content-Length: {$filesize}"); header('Accept-Ranges: none'); header('Content-Disposition: inline' . ";filename=\"{$encodedFilename}\";filename*=UTF-8''{$encodedFilename}"); header('Cache-Control: private'); // Workarounds for IE weirdness header('Pragma: public'); fpassthru($this->fs->readStream($imagePath)); exit; ImageUtils::downloadImage($this->fs, $imagePath, $imgName); } Loading ImageUtils.php +14 −0 Original line number Diff line number Diff line Loading @@ -30,4 +30,18 @@ class ImageUtils return new Filesystem($adapter); } public static function downloadImage(Filesystem $fs, string $path, string $name){ $mimetype = 'application/octet-stream'; $filesize = $fs->fileSize($path); $encodedFilename = urlencode($name); header("Content-Type: {$mimetype}"); header("Content-Length: {$filesize}"); header('Accept-Ranges: none'); header('Content-Disposition: inline' . ";filename=\"{$encodedFilename}\";filename*=UTF-8''{$encodedFilename}"); header('Cache-Control: private'); // Workarounds for IE weirdness header('Pragma: public'); fpassthru($fs->readStream($path)); exit; } } No newline at end of file Loading
ArticleImageDataHandler.inc.php +1 −12 Original line number Diff line number Diff line Loading @@ -43,18 +43,7 @@ class ArticleImageDataHandler extends ArticleHandler ->formatFilename($file->getData('path'), $file->getLocalizedData('path')); $pathInfo = pathinfo($filename); $imagePath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $pathInfo['filename'] . DIRECTORY_SEPARATOR . $imgName; $mimetype = 'application/octet-stream'; $filesize = $this->fs->fileSize($imagePath); $encodedFilename = urlencode($imgName); header("Content-Type: $mimetype"); header("Content-Length: $filesize"); header('Accept-Ranges: none'); header('Content-Disposition: attachment' . ";filename=\"$encodedFilename\";filename*=UTF-8''$encodedFilename"); header('Cache-Control: private'); // Workarounds for IE weirdness header('Pragma: public'); fpassthru($this->fs->readStream($imagePath)); exit(); ImageUtils::downloadImage($this->fs, $imagePath, $imgName); } return NULL; Loading
BookImageDataHandler.inc.php +1 −12 Original line number Diff line number Diff line Loading @@ -49,18 +49,7 @@ class BookImageDataHandler extends CatalogBookHandler $pathInfo = pathinfo($publicationFile->getData('path')); $imagePath = $pathInfo['dirname'] . DIRECTORY_SEPARATOR . $pathInfo['filename'] . DIRECTORY_SEPARATOR . $imgName; $mimetype = $file->mimetype ?? 'application/octet-stream'; $filesize = $this->fs->fileSize($imagePath); $encodedFilename = urlencode($imgName); header("Content-Type: {$mimetype}"); header("Content-Length: {$filesize}"); header('Accept-Ranges: none'); header('Content-Disposition: inline' . ";filename=\"{$encodedFilename}\";filename*=UTF-8''{$encodedFilename}"); header('Cache-Control: private'); // Workarounds for IE weirdness header('Pragma: public'); fpassthru($this->fs->readStream($imagePath)); exit; ImageUtils::downloadImage($this->fs, $imagePath, $imgName); } Loading
ImageUtils.php +14 −0 Original line number Diff line number Diff line Loading @@ -30,4 +30,18 @@ class ImageUtils return new Filesystem($adapter); } public static function downloadImage(Filesystem $fs, string $path, string $name){ $mimetype = 'application/octet-stream'; $filesize = $fs->fileSize($path); $encodedFilename = urlencode($name); header("Content-Type: {$mimetype}"); header("Content-Length: {$filesize}"); header('Accept-Ranges: none'); header('Content-Disposition: inline' . ";filename=\"{$encodedFilename}\";filename*=UTF-8''{$encodedFilename}"); header('Cache-Control: private'); // Workarounds for IE weirdness header('Pragma: public'); fpassthru($fs->readStream($path)); exit; } } No newline at end of file