AWS S3 PHP SDK 2将对象复制到另一个存储桶错误“错误请求” 400
作者:互联网
我需要将对象从存储桶复制到另一个存储桶.我尝试使用以下代码:
$response = $s3->copyObject(
array(
'Bucket' => 'ORIGINAL BUCKET',
'Key' => 'OBJECT KEY',
'CopySource' => urlencode('ORIGINAL BUCKET' . '/' . 'OBJECT KEY')
), array(
'Bucket' => 'NEW BUCKET',
'Key' => 'NEW OBJECT KEY',
'CopySource' => urlencode('NEW BUCKET' . '/' . 'NEW OBJECT KEY')
)
);
但是我收到一个错误类型400 Bad Request:
object(Aws\S3\Exception\InvalidRequestException)[274]
protected 'response' =>
object(Guzzle\Http\Message\Response)[261]
protected 'body' =>
object(Guzzle\Http\EntityBody)[260]
protected 'contentEncoding' => boolean false
protected 'rewindFunction' => null
protected 'stream' => resource(299, stream)
protected 'size' => null
protected 'cache' =>
array (size=9)
...
protected 'customData' =>
array (size=0)
...
protected 'reasonPhrase' => string 'Bad Request' (length=11)
protected 'statusCode' => int 400
有人将copyObject的真实示例添加到另一个存储桶吗?
解决方法:
是的,我查看了文档,但是我不太了解如何配置“源”和“目标”,但是现在我了解了.谢谢!
$response = $s3->copyObject(
array(
'Bucket' => 'DESTINATION BUCKET',
'Key' => 'DESTINATION OBJECT KEY',
'CopySource' => urlencode('SOURCE BUCKET' . '/' . 'SOURCE OBJECT KEY')
)
);
标签:amazon-s3,php 来源: https://codeday.me/bug/20191122/2062386.html