I have a script that links to my AWS S3 service. It's a test script that creates a random bucket and puts a text file in the bucket.
When executed via SSH [root@html] php ./sample.php
it executes without errors, the bucket is create and the file is created in the bucket.
However when I try to run via browser, it stops just before the command line to create the bucket and the script seems to end suddenly. The browser does not display any error message.
I'm not sure what it is that I'm missing out on. I've tried on Safari, IE 9, Chrome and Firefox. All gave a similar result.
Below is the script mentioned above,
<?php
// Include the SDK using the Composer autoloader
require 'vendor/autoload.php';
use Aws\S3\S3Client;
$client = S3Client::factory();
$bucket = uniqid("php-sdk-sample-", true);
echo "Creating bucket named {$bucket}
"; <--- This line displayed when run from browser
$result = $client->createBucket(array('Bucket' => $bucket));
// Wait until the bucket is created
$client->waitUntilBucketExists(array('Bucket' => $bucket));
$key = 'hello_world.txt';
echo "Creating a new object with key {$key}
";
$result = $client->putObject(array(
'Bucket' => $bucket,
'Key' => $key,
'Body' => "Hello World!"));
echo "Downloading that same object:
";
$result = $client->getObject(array(
'Bucket' => $bucket,
'Key' => $key));
echo "
---BEGIN---
";
echo $result['Body'];
echo "
---END---
";
?>