2011-04-11 28 views
0

我的用户可以通过编程方式将图像上传到AWS S3存储桶。但使用相同的PHP S3类包括(其中包含看跌的情况下以及本删除情况如下) - 他们无法删除文件:可以编程方式将其分配给Amazon S3存储桶但不能删除

 case 'DELETE': 
      curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE'); 
     break; 

所以我想知道如果任何在那里可以看到我在剧本中缺少的东西。我没有收到任何错误消息。 -Thanks

//THIS WORKS 

       //include the S3 class 
      if (!class_exists('S3'))require_once('S3.php'); 

    //GET keys 
    include_once "scripts/S3k.php"; 


//instantiate the class 
$s3 = new S3(awsAccessKey, awsSecretKey);  

    //assigns file location var to get 
    $fileTempName = $DestinationFile; 
    //Assigns S3 path/file name 
    $fileName = $path.$user_id."/".$fileName; 

//Move the file over to S3 
    if ($s3->putObjectFile($fileTempName, $mybucket, $fileName, S3::ACL_PUBLIC_READ)) { 
    echo " file uploaded"; 
}    


//THIS doesn't WORKS 

//include the S3 class 
if (!class_exists('S3'))require('S3.php'); 

//get KEYS 
include "scripts/S3k.php"; 

//instantiate the class 
    $s3 = new S3(awsAccessKey, awsSecretKey);  

//Assigns S3 path/file name 
    $fileName = $path.$user_id."/".$image_link; 

//Deletes the file in S3 
    if ($s3->deleteObject($mybucket, $fileName)) { 
    echo "Deleted file."; 
}    

//And this GET script doesn't work either. 
    $image_link = "1/Bowery_3_58x46app.jpg"; 
    $pathS3 = "http://d21v2uajc20x0x.cloudfront.net/myGallerist/artWorkImages/"; 

//include the S3 class 
if (!class_exists('S3'))require_once('S3.php'); 

include_once "scripts/S3k.php"; 

//instantiate the class 
$s3 = new S3(awsAccessKey, awsSecretKey);  

// Get the file from S3 

    if ($s3->getObject($mybucket, $pathS3.$image_link, "tempImage/".$image_link)) {   

     } else { 

      // Couldn't move the file over. 
      $msgToUser = 'No file was uploaded.'; 
    } 
+0

请将您在S3响应中收到的错误消息发布到您的DELETE请求中。 – 2011-04-11 23:04:05

回答

1

我可能是错的,但看起来它可能是与斗名称的问题,在删除您使用的是可变的,其中在放对象已硬编码桶名称bucketname,可以请确认变量是否包含正确的存储桶名称?

编辑: 你也应该尝试在两种情况下回显$ fileName,并确保它们完全相同。

+0

感谢您的回复。不,这些水桶名称都是“手机”。认为最好用这个问题的替代品取而代之,我只是错误地替换了其中一个。 – artworthy 2011-04-12 12:47:13

+0

以及$ fileName。那些是正确的?另外请发布你删除的S3错误。 – 2011-04-12 12:49:53

+0

是的,$ fileName检出。与PUT脚本相同的设置。没有错误信息。我刚刚添加了一个getObject脚本,该脚本也没有错误消息。 - 谢谢,艾伦 – artworthy 2011-04-12 15:29:44

相关问题