Created
June 3, 2024 04:35
-
-
Save komputronika/7783be7b64775276ffaa6c6589dfb2bc 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,37 @@ <?php use Aws\S3\S3Client; use Aws\S3\Exception\S3Exception; $temp_file ="mydoc.pdf"; $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"), ], ]); try { $result = $client->putObject( [ "Bucket" => getenv("BIZ_BUCKET_NAME"), "Key" => $folder . "/" . $nama_file, // <string || resource || Psr\Http\Message\StreamInterface> "Body" => fopen($temp_file, "r"), // 'private|public-read|public-read-write|authenticated-read|aws-exec-read|bucket-owner-read|bucket-owner-full-control' "ACL" => "private", ]); } catch (S3Exception $e) { echo "Upload failed"; die(); } ?>