[英]AWS S3 gives InvalidDigest [The Content-MD5 you specified was invalid] Error while copy_object() is used
我已開始使用AWS S3服務,並成功創建了存儲桶以及將對象上傳到任何存儲桶。 但是,當我嘗試將對象從一個存儲桶復制到另一個存儲桶時,在響應中出現了此異常。
我使用的庫是: http : //docs.aws.amazon.com/AWSSDKforPHP/latest/index.html#m=AmazonS3/copy_object
我得到的例外是:
[body] => CFSimpleXML Object
(
[Code] => InvalidDigest
[Message] => The Content-MD5 you specified was invalid
)
[status] => 400
我使用的示例代碼是:
$Connection = new AmazonS3(array(
'key' => AWS_KEY,
'secret' => AWS_SECRET_KEY
));
$Connection->set_hostname($HOST);
$Connection->allow_hostname_override(false);
$Connection->enable_path_style();
$res = $Connection->copy_object(
array('bucket' => $bucket, 'filename' => ("boxdata/asset4053/images/yesteryear.png")),
array('bucket' => $bucket, 'filename' => 'test123.png'),
array('acl' => AmazonS3::ACL_PUBLIC,
'storage' => AmazonS3::STORAGE_STANDARD,
'metadataDirective' => 'COPY')
);
非常感謝!
這是一個老問題,但我遇到了同樣的問題並找到了解決方案。 在發送到copy_object的選項列表中,添加NoContentMD5 => true。
$res = $Connection->copy_object(
array('bucket' => $bucket, 'filename' => 'test123.png'),
array('bucket' => $bucket, 'filename' => 'test456.png'),
array('NoContentMD5' => true)
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.