2016-03-20 144 views
0

嘗試使用copyObject命令(AWS S3)時出現以下錯誤。我使用的是AWS PHP SDK,這裏是代碼:使用AWS S3 CopyObject命令時未找到密鑰

$this->client->copyObject(array(
    'Bucket'  => 'lms-courses', 
    'Key'  => 'ideasfile.zip', 
    'CopySource' => "lms-courses/lalala.zip", 
)); 

Error executing "CopyObject" on " https://s3-us-west-2.amazonaws.com/lms-courses/ideasfile.zip "; AWS HTTP error: Client error: PUT https://s3-us-west-2.amazonaws.com/lms-courses/ideasfile.zip resulted in a 404 Not Found response: NoSuchKey The specified key does not exist.lalala.zipE698888 (truncated...) NoSuchKey (client): The specified key does not exist. - NoSuchKey The specified key does not exist.lalala.zipE698888912B810F7DfHtqN5Hls4hGdTGY/pVv36XZPzoM4mJ5fAdhJjEjDufNUArvKCrqN27SjiG06u5hnC8G8yPdzA=

我一直在掙扎與此錯誤一段時間了。水桶lms-courses存在,ideasfile.zip也存在。我甚至手動將該文件添加到存儲桶中,只是爲了以這種方式進行測試 - 以防上傳不當或其他問題。

我不明白爲什麼它說密鑰不存在,當它顯然是 - 我正在看它。

回答

4

錯誤表示源對象lalala.zip不存在。你確定lms-courses/lalala.zip存在嗎?

根據Copy an Object Using the AWS SDK for PHP

// Copy an object. 
$s3->copyObject(array(
    'Bucket'  => $targetBucket, 
    'Key'  => $targetKeyname, 
    'CopySource' => "{$sourceBucket}/{$sourceKeyname}", 
)); 
+0

03,我有這樣的事情向後的全部時間 - ideasfile.zip和lalala.zip需要被交換。我是一個白癡。 – xil3