Created
June 3, 2024 04:23
-
-
Save komputronika/f7d917f4f038b95ac2f0651941b51fe2 to your computer and use it in GitHub Desktop.
Revisions
-
komputronika created this gist
Jun 3, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ <?php use Aws\S3\S3Client; use Aws\S3\Exception\S3Exception; $key = "myfolder/myfile.ext"; $client = new S3Client([ "version" => "latest", "region" => getenv("BIZ_ACCESS_REGION"), "endpoint" => "https://" . getenv("BIZ_ENDPOINT"), "credentials" => [ "key" => getenv("BIZ_ACCESS_KEY_ID"), "secret" => getenv("BIZ_ACCESS_KEY_SECRET"), ], ]); $result = $client->getObject([ "Bucket" => getenv("BIZ_BUCKET_NAME"), "Key" => $key, ]); $body = $result->get("Body"); $body->rewind(); // Add http header here, for example: // header('Content-Type: application/pdf'); // header('Content-Disposition: inline; filename="mydoc.pdf"'); echo $body; ?>