proxy files instead of redirecting

This commit is contained in:
Jonas Leder 2021-09-26 00:05:13 +02:00
parent 10741033d5
commit 97f49d44ee
No known key found for this signature in database
GPG key ID: CC3C488E27DFF5CA

View file

@ -24,4 +24,15 @@ $presignedRequest = $s3Client->createPresignedRequest($command, '60 minutes');
// Get the actual presigned-url
$downloadURL = (string) $presignedRequest->getUri();
header("Location: $downloadURL");
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $downloadURL);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt ($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, true);
$content = curl_exec ($curl);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
header('Content-Type: ' . $contentType);
echo($content);