2011-04-11 4 views
0

내 사용자는 이미지를 AWS S3 버킷 벌금에 프로그래밍 방식으로 업로드 할 수 있습니다. 그래서프로그래밍 방식으로 Amazon S3 버킷에 PUT을 삽입 할 수 있지만 삭제하지 않을 수 있습니다.

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

내가 어떤 궁금 해요 : 그들은 파일을 삭제할 수 없습니다 -하지만 같은 PHP는 S3 클래스를 사용합니다 (풋 경우뿐만 아니라이 삭제 경우 아래를 포함하는) 포함 날카로운 눈이 내 대본에없는 것을 볼 수 있습니다. 오류 메시지가 표시되지 않습니다.

//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

DELETE 요청에 대한 S3 응답의 오류 메시지를 게시하십시오. –

답변

1

내가 잘못 될 수 고마워요 있지만 버킷 이름으로 문제가 될 수있는 것 같다에서 할 수있다, 당신은 넣어 객체로 열심히 버킷 이름을 코딩 한 bucketname 같은 변수를 사용하여 삭제 변수에 올바른 버킷 이름이 포함되어 있는지 확인하십시오.

편집 : 또한 두 경우 모두 $ fileName을 에코하려고 정확하게 일치하는지 확인해야합니다.

+0

답장을 보내 주셔서 감사합니다. 아니요, 양동이 이름은 모두 "mobiarts"였습니다. 이 질문에 대해서 바스 (vars)로 바꾸는 것이 가장 좋을 것이라고 생각했는데 실수로 그 중 하나만 바꿨습니다. – artworthy

+0

그리고 $ fileName은 어떨까요? 맞습니까? 또한 삭제시 발생하는 S3 오류를 게시하십시오. –

+0

예, $ fileName이 체크 아웃합니다. PUT 스크립트와 동일한 설정. 오류 메시지가 없습니다. 방금 w/o 오류 메시지가 깨진 getObject 스크립트를 추가했습니다. -thanks, Allen – artworthy