2012-01-03 113 views
0

我想上傳用戶視頻文件到Amazon Trough S3 Class,但它給出以下Errors.my密鑰和密鑰是有效的。 1 = S3 :: putBucket(my_bucket_name,public-read,):[SignatureDoesNotMatch]我們計算的請求籤名與您提供的簽名不匹配。檢查您的密鑰和簽名方法也是錯誤是 「上傳文件時出現問題...抱歉。」 任何人都知道爲什麼這是行不通的?上傳視頻文件到亞馬遜通過S3

<?php 

error_reporting(E_ERROR | E_WARNING | E_PARSE); 

if (!class_exists('S3'))require_once('S3.php'); 
if (!defined('awsAccessKey')) define('awsAccessKey', 'xxxxxxxxxxxx'); 
if (!defined('awsSecretKey')) define('awsSecretKey', 'yyyyyyyyyyyy'); 

$s3 = new S3(xxxxxxxxx,yyyyyyyyy); 

    if(isset($_POST['Submit'])){ 
$fileName = $_FILES['theFile']['name']; 
$fileTempName = $_FILES['theFile']['tmp_name']; 
$s3->putBucket("hotfit", S3::ACL_PUBLIC_READ,'EU'); 

if ($s3->putObjectFile($fileTempName, "hotfit", $fileName, S3::ACL_PUBLIC_READ)) { 
    echo "We successfully uploaded your file."; 
    }else{ 
    echo "Something went wrong while uploading your file... sorry."; 
    } 

    $bucket_contents = $s3->getBucket("hotfit"); 

    foreach ($bucket_contents as $file){ 
    $fname = $file['name']; 
    $furl = "http://hotfit.s3.amazonaws.com/".$fname; 
    echo "<a href=\"$furl\">$fname</a><br />"; 
} 
} 

?> 

<form action="" method="post" enctype="multipart/form-data"> 
    <input name="theFile" type="file" /> 
    <input name="Submit" type="submit" value="Upload"> 
</form> 

回答

0

看起來像你的代碼是好的,但我想將這個

 <form action="" method="post" enctype="multipart/form-data"> 
     <input name="theFile" type="file" /> 
     <input name="Submit" type="submit" value="Upload"> 
     </form> 

低於這個

if(isset($_POST['Submit'])){ 
    $fileName = $_FILES['theFile']['name']; 
    $fileTempName = $_FILES['theFile']['tmp_name']; 
    } 

,改變

$s3->putBucket("hotfit", S3::ACL_PUBLIC_READ,'EU'); 

$s3->putBucket("hotfit", S3::ACL_PUBLIC_READ); 

希望工程

+0

我試圖這可能是它的工作 – 2012-01-05 07:47:23

+1

u需要做鬥來存儲用戶上傳的視頻,當用戶點擊提交併顯示所有上傳的視頻只不過是你沒有在foreach循環ü了這一切事情你只需要合成你的代碼,以便按照你想要的方式工作 – 2012-01-05 07:52:16

+0

thanx的建議 – 2012-01-05 07:54:25