render images through imgproxy

This commit is contained in:
Jonas Leder 2022-04-16 23:34:35 +02:00
parent d465f5ecb8
commit 8c5b68037a
No known key found for this signature in database
GPG key ID: CC3C488E27DFF5CA
2 changed files with 8 additions and 2 deletions

View file

@ -1,6 +1,7 @@
<?php
use GraphQL\Server\StandardServer;
use GraphQL\Type\Schema;
use GraphQL\Error\DebugFlag;
require 'vendor/autoload.php';
require "./lib/config.php";
@ -17,7 +18,8 @@ try {
'schema' => $schema,
'rootValue' => [
'db' =>$conn,
]
],
'debugFlag' => DebugFlag::INCLUDE_DEBUG_MESSAGE | DebugFlag::INCLUDE_TRACE,
];
$server = new StandardServer($serverConfig);

View file

@ -28,7 +28,11 @@ function getSkills() {
// Get the actual presigned-url
$downloadURL = (string) $presignedRequest->getUri();
array_push($response, $downloadURL);
$encodedUrl = rtrim(strtr(base64_encode($downloadURL), '+/', '-_'), '=');
$path = "/rs:fit:0:80:1/g:no/{$encodedUrl}.png";
$signature = rtrim(strtr(base64_encode(hash_hmac('sha256', $imgProxySalt.$path, $imgProxyKey, true)), '+/', '-_'), '=');
array_push($response, $imgProxyUrl . "/" . $signature . $path);
}
return $response;
}