some fixes
This commit is contained in:
parent
36fd693728
commit
ab27e0a74d
|
@ -49,7 +49,7 @@ $avatarCallback = function (string $type, string $code, int $width, int $height,
|
|||
$response
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT')
|
||||
->setContentType('image/png')
|
||||
->send($data)
|
||||
->file($data)
|
||||
;
|
||||
unset($image);
|
||||
};
|
||||
|
@ -156,7 +156,7 @@ App::get('/v1/avatars/image')
|
|||
$response
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT')
|
||||
->setContentType('image/png')
|
||||
->send($data)
|
||||
->file($data)
|
||||
;
|
||||
unset($image);
|
||||
});
|
||||
|
@ -287,7 +287,7 @@ App::get('/v1/avatars/favicon')
|
|||
$response
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT')
|
||||
->setContentType('image/png')
|
||||
->send($data)
|
||||
->file($data)
|
||||
;
|
||||
unset($image);
|
||||
});
|
||||
|
@ -329,7 +329,7 @@ App::get('/v1/avatars/qr')
|
|||
$response
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache
|
||||
->setContentType('image/png')
|
||||
->send($image->output('png', 9))
|
||||
->file($image->output('png', 9))
|
||||
;
|
||||
});
|
||||
|
||||
|
@ -411,6 +411,6 @@ App::get('/v1/avatars/initials')
|
|||
$response
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + (60 * 60 * 24 * 45)) . ' GMT') // 45 days cache
|
||||
->setContentType('image/png')
|
||||
->send($image->getImageBlob())
|
||||
->file($image->getImageBlob())
|
||||
;
|
||||
});
|
||||
|
|
|
@ -960,7 +960,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview')
|
|||
$response
|
||||
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + 60 * 60 * 24 * 30) . ' GMT')
|
||||
->setContentType($contentType)
|
||||
->send($data)
|
||||
->file($data)
|
||||
;
|
||||
unset($image);
|
||||
});
|
||||
|
|
|
@ -307,7 +307,7 @@ App::shutdown()
|
|||
$useCache = $route->getLabel('cache', false);
|
||||
if ($useCache) {
|
||||
$data = $response->getPayload();
|
||||
if (!empty($data)) {
|
||||
if (!empty($data['payload'])) {
|
||||
$key = md5($request->getURI() . implode('*', $request->getParams()));
|
||||
$cacheLog = $dbForProject->getDocument('cache', $key);
|
||||
if ($cacheLog->isEmpty()) {
|
||||
|
@ -319,11 +319,14 @@ App::shutdown()
|
|||
$cacheLog->setAttribute('accessedAt', \time());
|
||||
Authorization::skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), $cacheLog));
|
||||
}
|
||||
if (!empty($data['payload'])) {
|
||||
$data['payload'] = base64_encode($data['payload']);
|
||||
$cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()));
|
||||
$cache->save($key, json_encode($data));
|
||||
}
|
||||
|
||||
$data = [
|
||||
'content-type' => $response->getContentType(),
|
||||
'payload' => base64_encode($data['payload']),
|
||||
] ;
|
||||
|
||||
$cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId()));
|
||||
$cache->save($key, json_encode($data));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -449,7 +449,6 @@ class Response extends SwooleResponse
|
|||
return $this->payload;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output response
|
||||
*
|
||||
|
@ -459,17 +458,15 @@ class Response extends SwooleResponse
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function send(string $body = ''): void
|
||||
public function file(string $body = ''): void
|
||||
{
|
||||
$this->payload = [
|
||||
'content-type' => $this->getContentType(),
|
||||
'payload' => $body
|
||||
'payload' => $body
|
||||
];
|
||||
|
||||
parent::send($body);
|
||||
$this->send($body);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* YAML
|
||||
*
|
||||
|
@ -501,7 +498,6 @@ class Response extends SwooleResponse
|
|||
return $this->payload;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to set a response filter
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue