website/public/API/getFile.php
2021-05-13 22:32:19 +02:00

26 lines
759 B
PHP

<?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();