从Amazon S3删除图像文件

时间:2015-10-19 11:29:29

标签: php amazon-web-services amazon-s3 delete-file

以下是我删除Amazon S3图片文件的代码:

<?php

$s3 = new S3(awsAccessKey, awsSecretKey);
$del1 = $s3->deleteObject($bucket,$newfilename);
$del2 = $s3->deleteObject($thumb_bucket,$newfilename);

public static function deleteObject($bucket, $uri)
    {
        $rest = new S3Request('DELETE', $bucket, $uri, self::$endpoint);
        $rest = $rest->getResponse();
        if ($rest->error === false && $rest->code !== 204)
            $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
        if ($rest->error !== false)
        {
            self::__triggerError(sprintf("S3::deleteObject(): [%s] %s",
            $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
            return false;
        }
        return true;
    }
?>

在此,我 输出 ,但 形成我的存储桶,不会被删除 。任何解决方案?

0 个答案:

没有答案