putObject は私にとってはうまく機能します。しかし、getObjectURL s3 を実行すると、Access Denied で応答します。ポリシーなどを設定するさまざまな方法を調べましたが、まだ運がありません。どんな助けでも大歓迎です!
putObject コード:
$this->load->library('aws');
$temporary_png_path = tempnam(sys_get_temp_dir(), 'sig') . $upload_data['file_ext'];
$document_s3_key = 'profile_pictures/'.$user->id.'/profile_'.$user->id.$upload_data['file_ext'];
$resource = fopen($upload_data['full_path'], 'r');
try{
$aws_object=$this->aws->putObject(array(
'Bucket' => 'tbucket',
'Key' => $document_s3_key,
'SourceFile' => $resource,
'Body' => $resource,
'ContentType' => 'image/jpeg'
));
}
catch (Exception $e)
{
$error = "Something went wrong saving your file.\n".$e;
echo $error;
}
getObjectURL コード:
$this->load->library('aws');
$profile_image = $this->aws->getObjectUrl('tbucket', 'profile_pictures/'.$user->id.'/'.'profile_'.$user->id.'.jpeg');
$this->data['image'] = ($profile_image == '')? "/public/images/avatar-large.jpg" : $profile_image;
AWS のアクセス許可:
Authenticated Users => All Permissions enabled
バケット ポリシー:
{
"Version": "2008-10-17",
"Id": "Policynumber",
"Statement": [
{
"Sid": "Stmtnumber",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::number:user/t_master"
},
"Action": [
"s3:GetObjectAcl",
"s3:GetObjectTorrent",
"s3:GetObjectVersion",
"s3:GetObjectVersionAcl"
],
"Resource": "arn:aws:s3:::tbucket/*"
}
]
}