2021-05-13 22:32:19 +02:00
|
|
|
<?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
|
2021-05-13 23:07:03 +02:00
|
|
|
$presignedRequest = $s3Client->createPresignedRequest($command, '60 minutes');
|
2021-05-13 22:32:19 +02:00
|
|
|
|
|
|
|
// Get the actual presigned-url
|
2021-05-13 23:07:03 +02:00
|
|
|
$downloadURL = (string) $presignedRequest->getUri();
|
|
|
|
header("Location: $downloadURL");
|