2014-01-08 42 views
1

我有一個S3存儲桶,裏面有200萬個MP3文件,有時候客戶點了一個mp3文件,但是他們無法從我們的S3下載文件桶。在我去請求從內容提供者處重新傳送文件之前,我想創建一個簡單的腳本,以便檢查文件是否存在於S3存儲桶中。我寫了一個腳本來檢查水桶,但它是我不斷收到此錯誤:AWSSDK - S3 - if_object_exists不斷返回參數2傳遞給Guzzle錯誤

Catchable fatal error: Argument 2 passed to Guzzle\Service\Client::getCommand() must be an array, string given, called in phar:///mnt/universal_portal/prod/download/aws.phar/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 93 and defined in phar:///mnt/universal_portal/prod/download/aws.phar/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php on line 113

這是我一直打算關閉這Amazon鏈接我寫

require_once('appsettings.php'); 
require 'aws.phar'; 

use Aws\S3\S3Client; 

$client = S3Client::factory(array(
    'key' => $aws_key, 
    'secret' => $aws_secret 
)); 

$filename = '000002422704.mp3' . strtolower($aws_key); 
$info = $client->if_object_exists($aws_bucket,$filename); 

return $info; 

代碼,但我無法讓這個文件檢查工作。

任何幫助,非常感謝。

乾杯

回答

4

您發佈的鏈接爲SDK 1.x.您正在使用的Phar文件和實例是SDK 2.x.他們都需要是相同的版本。 :)

您正在尋找SDK 2.x中的Aws\S3\S3Client::doesObjectExist()

+0

Facepalm!感謝隊友,甚至在我使用它時都沒有看到。 – TimLavelle