gpt4 book ai didi

php - AWS S3 PHP SDK 2 Copy an object to another bucket 错误 'Bad request' 400

转载 作者:搜寻专家 更新时间:2023-10-31 20:42:38 25 4
gpt4 key购买 nike

我需要将一个对象从一个存储桶复制到另一个存储桶。我尝试使用这段代码:

   $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

有人有将对象复制到另一个桶的真实示例吗?

最佳答案

是的,我看过文档,但我不太了解如何配置“源”和“目标”,但现在我明白了。谢谢!

  $response = $s3->copyObject(
array(
'Bucket' => 'DESTINATION BUCKET',
'Key' => 'DESTINATION OBJECT KEY',
'CopySource' => urlencode('SOURCE BUCKET' . '/' . 'SOURCE OBJECT KEY')
)
);

关于php - AWS S3 PHP SDK 2 Copy an object to another bucket 错误 'Bad request' 400,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18770420/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com