[英]Set permissions on accessing a certain file on S3 using IAM with the PHP SDK?
[英]Grant IAM User Permissions to AWS S3 File Through AWS PHP SDK
是否可以通過AWS PHP SDK授予特定IAM用戶或組對AWS S3文件的完全權限?
我嘗試了以下命令:
// Grant permissions via user id
$s3->putObjectAcl(array(
'Bucket' => '[Bucket name]',
'Key' => '[File location in bucket]',
'Grants' => array(
array(
'Grantee' => array(
'ID' => '[User ID from IAM API]',
'Type' => 'CanonicalUser'
),
'Permission' => 'FULL_CONTROL'
)
)
));
// Grant permissions via group id
$s3->putObjectAcl(array(
'Bucket' => '[Bucket name]',
'Key' => '[File location in bucket]',
'Grants' => array(
array(
'Grantee' => array(
'ID' => '[Group ID from IAM API]',
'Type' => 'Group'
),
'Permission' => 'FULL_CONTROL'
)
)
));
但是他們總是拋出以下錯誤:
Argument format not recognized
有人可以告訴我我在做什么錯嗎?
任何幫助將不勝感激。
在上面的代碼中,您沒有指定SourceFile,因此拋出了錯誤。 這是更新的代碼,它將幫助您解決此問題。
// Grant permissions via user id
$s3->putObjectAcl(array(
'Bucket' => '[Bucket name]',
'Key' => '[File location in bucket]',
'SourceFile' => '[File to be uploaded location]', // add this line
'Grants' => array(
array(
'Grantee' => array(
'ID' => '[User ID from IAM API]',
'Type' => 'CanonicalUser'
),
'Permission' => 'FULL_CONTROL'
)
)
));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.