2014-12-06 51 views
1

S3中的項目如何使用新的AWS S3 PHP SDK以'public-read'進行更新:似乎只有GET和PUT可能? http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.S3.S3Client.html使用新的PHP SDK更新AWS S3項目ACL

迭代器返回一個數組,而不是一個類。獲取對象返回一個類,但沒有明顯的方法來更新。 CopyObject似乎有點黑客?

$s3->copyObject(array(
     'Bucket'  => 'media', 
     'Key'  => $k, 
     'CopySource' => 'media'.'/'.$k, 
     'ACL'  => 'public-read', 
)); 

回報:

比從未
PHP Fatal error: Uncaught Aws\S3\Exception\InvalidRequestException: AWS Error Code: InvalidRequest, Status Code: 400, AWS Request ID: FC630F89A049823A, AWS Error Type: client, AWS Error Message: This copy request is illegal because it is trying to copy an object to itself without changing the object's metadata, storage class, website redirect location or encryption attributes., User-Agent: aws-sdk-php2/2.5.3 Guzzle/3.8.1 curl/7.35.0 PHP/5.5.9-1ubuntu4.4 thrown in /.../vendor/aws/aws-sdk-php/src/Aws/Common/Exception/NamespaceExceptionFactory.php on line 91 

回答

1

猶未晚。

$s3Client->putObjectAcl(array(
    'Bucket'  => 'yourbucket', 
    'Key'  => 'yourkey', 
    'ACL' => 'public-read' 
));