Skip to content

Commit 46e106a

Browse files
committed
fix content type logic
1 parent 43f6073 commit 46e106a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/controllers/api/storage.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,10 +944,16 @@
944944
$cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId() . DIRECTORY_SEPARATOR . $bucketId . DIRECTORY_SEPARATOR . $fileId)); // Limit file number or size
945945
$data = $cache->load($key, 60 * 60 * 24 * 30 * 3/* 3 months */);
946946

947-
$output = (empty($output)) ? ( empty($type) ? 'jpg' : $type ) : $output;
947+
948+
$contentType = in_array($mime, $outputs) ? $mime : $outputs['jpg'];
949+
950+
if(!empty($output) && \array_key_exists($output, $outputs)) {
951+
$contentType = $outputs[$output];
952+
}
953+
948954
if ($data) {
949955
return $response
950-
->setContentType((\array_key_exists($output, $outputs)) ? $outputs[$output] : $outputs['jpg'])
956+
->setContentType($contentType)
951957
->addHeader('Expires', $date)
952958
->addHeader('X-Appwrite-Cache', 'hit')
953959
->send($data)

0 commit comments

Comments
 (0)