I have an amazon workmail email address setup to automatically forward email to an s3 bucket. I then have a php file that grabs the raw email file from the s3 bucket and then delete it (every 2 minutes).
Anyway my issue is I have the s3 bucket set to public access. however when an object is placed in the bucket it is not automatically given a permission level of public access. So I think i did something wrong??
I am using the Amazon pkp SDK to connect to the bucket with an IAM_KEY and IAM_SECRET . However i am finding that I still have to manually make the objects in the bucket public in order to access them??
Here is my aws sdk code
//Include the AWS SDK using the Composer autoloader.
require 'awssdk/aws-autoloader.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// AWS Info
$bucketName = 'pipedemail';
$IAM_KEY = '***';
$IAM_SECRET = '***';
// Connect to AWS
try {
// You may need to change the region. It will say in the URL when the bucket is open
// and on creation. us-east-2 is Ohio, us-east-1 is North Virgina
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => $IAM_KEY,
'secret' => $IAM_SECRET
),
'version' => 'latest',
'region' => 'us-east-1'
)
);
} catch (Exception $e) {
// We use a die, so if this fails. It stops here. Typically this is a REST call so this would
// return a json object.
die("Error: " . $e->getMessage());
}