admin管理员组文章数量:1279212
I'm using AWS SDK for PHP (Version 3) to configure S3 bucket lifecycle rules via PutBucketLifecycleConfiguration
. However, I’m getting the following error:
Aws\S3\Exception\S3Exception: Error executing "PutBucketLifecycleConfiguration" on "http://ceph:8000/testcachebucket?lifecycle"; AWS HTTP error: Client error: `PUT http://ceph:8000/testcachebucket?lifecycle` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidRequest</Code><Message>Missing required header for this reques (truncated...)
InvalidRequest (client): Missing required header for this request: Content-MD5 - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidRequest</Code><Message>Missing required header for this request: Content-MD5</Message><BucketName>testcachebucket</BucketName><RequestId>tx000000000000000000608-0067bc52d0-16f97-default</RequestId><HostId>16f97-default-default</HostId></Error>
According to the AWS documentation, the Content-MD5
header is required when making a REST API request. However, the PHP SDK documentation does not explain how to include it.
Here’s my current code:
$this->s3Client->PutBucketLifecycleConfiguration([
'Bucket' => $bucket,
'LifecycleConfiguration' => [
'Rules' => $opts,
],
]);
How can I correctly make a request that includes the Content-MD5
header in AWS SDK for PHP?
I'm using AWS SDK for PHP (Version 3) to configure S3 bucket lifecycle rules via PutBucketLifecycleConfiguration
. However, I’m getting the following error:
Aws\S3\Exception\S3Exception: Error executing "PutBucketLifecycleConfiguration" on "http://ceph:8000/testcachebucket?lifecycle"; AWS HTTP error: Client error: `PUT http://ceph:8000/testcachebucket?lifecycle` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidRequest</Code><Message>Missing required header for this reques (truncated...)
InvalidRequest (client): Missing required header for this request: Content-MD5 - <?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidRequest</Code><Message>Missing required header for this request: Content-MD5</Message><BucketName>testcachebucket</BucketName><RequestId>tx000000000000000000608-0067bc52d0-16f97-default</RequestId><HostId>16f97-default-default</HostId></Error>
According to the AWS documentation, the Content-MD5
header is required when making a REST API request. However, the PHP SDK documentation does not explain how to include it.
Here’s my current code:
$this->s3Client->PutBucketLifecycleConfiguration([
'Bucket' => $bucket,
'LifecycleConfiguration' => [
'Rules' => $opts,
],
]);
How can I correctly make a request that includes the Content-MD5
header in AWS SDK for PHP?
1 Answer
Reset to default 0Ok I finally found a "solution".
The problem comes from version of my Ceph server which is in Pacific version. Normally, middleware (ApplyChecksumMiddleware.php
) should add this check automatically, but this is not the case on older Ceph servers like mine.
Indeed, AWS has modified its SDK to use CRC32 or SHA instead of MD5 in recent versions, making compatibility with Ceph Pacific problematic.
Solution:
To get around this problem, simply add the following constraint to composer.json to prevent the installation of incompatible versions of the SDK:
“conflict": {
“aws/aws-sdk-php": ”^3.337”
}
This forces the use of an earlier version of the SDK that maintains the MD5 verification required by Ceph Pacific.
本文标签: aws php sdkAWS SDK PHP – How to add ContentMD5 for PutBucketLifecycleConfigurationStack Overflow
版权声明:本文标题:aws php sdk - AWS SDK PHP – How to add Content-MD5 for PutBucketLifecycleConfiguration? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741272938a2369568.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论