我不知道如何调试了。我使用https://gist.github.com/fowkswe/3db02f1d355cab1dc300
if(in_array($extension, $allowed)) {
$awsAccessKey = 'my key',
$awsSecretKey = 'my secret key',
$bucketName = 'my-bucket';
$endpoint = 's3-ap-southeast-1.amazonaws.com';
$s3 = new S3($awsAccessKey, $awsSecretKey, false, $endpoint);
$s3Filename = $time.baseName($fileName);
if ($s3 -> putObject($s3->inputFile($file), $bucketName, $s3Filename, S3::ACL_PUBLIC_READ)) {
echo "doesn\'t goes here"
}
else {
die('there was a problem');
}
}
也许是我的配置问题。这是我对s3的政策。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}