get static files from S3

This commit is contained in:
Jonas Leder 2021-05-13 22:32:19 +02:00
parent 0392b78e91
commit 9c1a1b9b36
11 changed files with 42 additions and 1 deletions

6
.gitignore vendored
View file

@ -9,4 +9,8 @@ public/js/
.sass-cache/
#node cache
node_modules/
node_modules/
#composer
public/API/vendor
public/API/composer.lock

6
public/API/composer.json Normal file
View file

@ -0,0 +1,6 @@
{
"require": {
"aws/aws-sdk-php": "^3.181",
"symforge/chilkat-php": "9.5.0.66"
}
}

26
public/API/getFile.php Normal file
View file

@ -0,0 +1,26 @@
<?php
include("./lib/config.php");
require 'vendor/autoload.php';
$s3Client = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'endpoint' => $S3Server,
'use_path_style_endpoint' => true,
'credentials' => [
'key' => $S3AccessKey,
'secret' => $S3SecretKey,
],
]);
// Get a command object from the client
$command = $s3Client->getCommand('GetObject', [
'Bucket' => $S3BucketName,
'Key' => $_GET["filename"]
]);
// Create a pre-signed URL for a request with duration of 10 miniutes
$presignedRequest = $s3Client->createPresignedRequest($command, '1000 minutes');
// Get the actual presigned-url
echo (string) $presignedRequest->getUri();

View file

@ -14,3 +14,8 @@ $footerMaxPost = 5;
$homeMaxPost = 3;
$trackURL = "";
$S3Server = "";
$S3AccessKey = "";
$S3SecretKey = "";
$S3BucketName = "";

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.