1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

fix content type logic

This commit is contained in:
Damodar Lohani 2022-03-18 11:07:54 +00:00
parent 43f60739d7
commit 46e106ab56

View file

@ -944,10 +944,16 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
$cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId() . DIRECTORY_SEPARATOR . $bucketId . DIRECTORY_SEPARATOR . $fileId)); // Limit file number or size
$data = $cache->load($key, 60 * 60 * 24 * 30 * 3/* 3 months */);
$output = (empty($output)) ? ( empty($type) ? 'jpg' : $type ) : $output;
$contentType = in_array($mime, $outputs) ? $mime : $outputs['jpg'];
if(!empty($output) && \array_key_exists($output, $outputs)) {
$contentType = $outputs[$output];
}
if ($data) {
return $response
->setContentType((\array_key_exists($output, $outputs)) ? $outputs[$output] : $outputs['jpg'])
->setContentType($contentType)
->addHeader('Expires', $date)
->addHeader('X-Appwrite-Cache', 'hit')
->send($data)