To use the PHP SDK, follow the steps below.
Below is a sample PHP file that configures the Stook Endpoint.
<?php
require 'aws/aws-autoloader.php';
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-east-1',
'endpoint' => 'Enter server info',
'use_path_style_endpoint' => true,
'credentials' => [
'key' => 'Enter Access Key',
'secret' => 'Enter Secret Key',
],
'http' => [
'verify' => false
]
]);
try {
$s3->createBucket(array('Bucket' => 'testbucket'));
}
catch (Exception $e){
echo "There is a bucket with that name!<br>";
}
// Sending a PutObject request and getting the results
$insert = $s3->putObject([
'Bucket' => 'testbucket',
'Key' => 'testkey',
'Body' => 'Hello world'
]);
// Download the contents of the object
$retrive = $s3->getObject([
'Bucket' => 'testbucket',
'Key' => 'testkey',
'SaveAs' => 'testkey_local'
]);
//Index the body to the result object
echo $retrive['Body'];