This has been driving me crazy for several days, and I know that I'm missing something simple. I've been attempting to update CORS for a bucket that I create on the fly using the PHP SDK.
This is what I've attempted to hack together out of the various tutorials that I've found: (one thing I'm not sure about is the prefered method of sending multiple AllowedMethods).
$result = $s3Client->putBucketCors(array( 'Bucket' => $bucket, 'CORSConfiguration' => array( array( 'AllowedOrigins' => array('AllowedOrigin' => '*'), 'AllowedMethods' => array('AllowedMethods' => 'POST'), 'AllowedMethods' => array('AllowedMethods' => 'GET'), 'AllowedMethods' => array('AllowedMethods' => 'PUT'), 'MaxAgeSeconds' => array('MaxAgeSeconds' => '3000'), 'AllowedHeader' => array('AllowedHeader' => '*') ) ) ));
The above returns the following error:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Found 1 error while validating the input provided for the PutBucketCors operation: [CORSConfiguration] must be an associative array.
I've tried to use the information from this page to help, but I know it is out of date: http://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.S3.S3Client.html#_putBucketCors
I've verified that the bucket exists and is created, through the AWS console. Any help would be greatly appreciated. Thank you!
Edit: I was able to pull my CORS off of an existing bucket, and this is what it gave me. Still trying to figure out how to set up my arrays to create:
data:Aws\Result:private] => Array ( [CORSRules] => Array (  => Array ( [AllowedHeaders] => Array (  => * ) [AllowedMethods] => Array (  => GET  => POST  => PUT ) [AllowedOrigins] => Array (  => * )[ MaxAgeSeconds] => 3000 ))