get skills directly from s3 server

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

View file

@ -18,7 +18,7 @@ class Skill extends HTMLElement {
skills.forEach(skill => {
const image = document.createElement("img");
image.classList.add("skills");
image.src = "/API/getFile.php?filename=" + skill;
image.src = skill;
this.appendChild(image);
});

View file

@ -17,7 +17,18 @@ function getSkills() {
$response = [];
foreach ($result["Contents"] as $skill){
array_push($response, $skill["Key"]);
// Get a command object from the client
$command = $s3Client->getCommand('GetObject', [
'Bucket' => $S3BucketName,
'Key' => $skill["Key"]
]);
// Create a pre-signed URL for a request with duration of 10 miniutes
$presignedRequest = $s3Client->createPresignedRequest($command, '60 minutes');
// Get the actual presigned-url
$downloadURL = (string) $presignedRequest->getUri();
array_push($response, $downloadURL);
}
return $response;
}