Search code examples
phpamazon-web-servicesamazon-s3fine-uploader

Display images uploaded by fineuploder to Amazon S3?


I have followed this tutorial http://blog.fineuploader.com/2013/08/16/fine-uploader-s3-upload-directly-to-amazon-s3-from-your-browser/ to upload images to Amazon S3 with fineuploader and uploading works fine. The problem is when I want to see a picture I have uploaded to S3.

I get the error

[06-Jan-2015 12:30:19 Europe/Berlin] PHP Fatal error:  Uncaught Aws\S3\Exception\AccessDeniedException: AWS Error Code: AccessDenied, Status Code: 403, AWS Request ID: 6F9935EA1BE9F4F5, AWS Error Type: client, AWS Error Message: Access Denied, User-Agent: aws-sdk-php2/2.7.12 Guzzle/3.9.2 curl/7.24.0 PHP/5.3.28 ITR
  thrown in /home/connecti/public_html/aws/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91

When I run this test exampel

<?php
require 'aws/aws-autoloader.php';
use Aws\S3\S3Client;

// Instantiate the S3 client with your AWS credentials
$s3 = S3Client::factory(array(

'key' => 'MY_KEY',
'secret' => 'MY_SECRET_KEY',
));


$bucket = 'MY_BUCKET';

// Use the high-level iterators (returns ALL of your objects).
$objects = $s3->getIterator('ListObjects', array('Bucket' => $bucket));

echo "Keys retrieved!\n";
foreach ($objects as $object) {
    echo $object['Key'] . "\n";
}

// Use the plain API (returns ONLY up to 1000 of your objects).
$result = $s3->listObjects(array('Bucket' => $bucket));

echo "Keys retrieved!\n";
foreach ($result['Contents'] as $object) {
    echo $object['Key'] . "\n";
}

?>

My key, secret key and bucket are correct!

Same with other examples.

What do I need to do? Can anyone give me an example how I show an image uploaded by fineuploader and if I have to do any setting on Amazon (in addition to what I have done from the fineuploader blog)?


Solution

  • The error message suggests that the server-side key does not have proper permissions to make a ListObjects or some related call on the bucket in question. You'll need to re-evaluate the IAM user/group associated with your server-side key and ensure it has all required assigned permissions.