请帮助我解决,我已经在Amazon s3中创建了一个存储桶以存储用户的个人资料照片。
我已经安装了aws SDK,还编写了硬编码以访问Amazon s3,但是不幸的是,我遇到了错误-
类型:InvalidArgumentException
消息:凭据必须是的实例 Aws \ Credentials \ CredentialsInterface,一个关联数组 包含“密钥”,“秘密”和一个可选的“令牌”键值对, 凭据提供程序功能,或者为false。
这是我的代码
public function user_profile_picture_upload()
{
if (empty($_FILES['newUserProfilePic']['name']))
{
// $this->load->view('app/users/user_profile_picture_view');
}
else
{
$random_string = random_string('alnum',3);
$name = $_FILES['newUserProfilePic']['name'];
$size = $_FILES['newUserProfilePic']['size'];
$tmp = $_FILES['newUserProfilePic']['tmp_name'];
$bucket = 'geetables-profile-picture';
if(!empty($tmp)){ // If Attachment Exist
$options = [
'region' => 'us-west-1','version' => 'latest','signature_version' => 'v4','credentials' => [
'key' => $this->config->item('key
','product_config'),'secret' => $this->config->item('secret
','product_config')]
];
$s3Client = new S3Client($options);
$image_name = $random_string.$name;
$file_uploaded = $s3Client->putObject([
'Bucket' => $bucket,'Key' => $image_name,'SourceFile' => $tmp,'ACL' => 'public-read'
]);
$image_path = $file_uploaded['ObjectURL'];
if ($_FILES['newUserProfilePic']['error'] == 0)
{
$profile_pic_indexed = $this->users_model->upload_profile_pic($image_path);
$data['msg'] = '<div class="alert alert-success">Profile picture uploaded</div>';
}
else {
$data['msg'] = '<div class="alert alert-danger">There was an error,please try again</div>';
}
}
$this->load->view('app/header/header_new');
$this->load->view('app/users/user_profile_picture_view',$data);
$this->load->view('app/footer/footer_new');
}
$this->load->view('app/header/header_new');
$this->load->view('app/users/user_profile_picture_view');
$this->load->view('app/footer/footer_new');
}
}