BaiduBCS::is_object_exist PHP Method

is_object_exist() public method

判断object是否存在
public is_object_exist ( string $bucket, string $object, array $opt = [] ) : boolean
$bucket string (Required)
$object string (Required)
$opt array (Optional)
return boolean true|boolean false|BCS_ResponseCore true:object存在 false:不存在 BCS_ResponseCore其他错误
    public function is_object_exist($bucket, $object, $opt = array())
    {
        $this->assertParameterArray($opt);
        $opt[self::BUCKET] = $bucket;
        $opt[self::METHOD] = 'HEAD';
        $opt[self::OBJECT] = $object;
        $response = $this->get_object_info($bucket, $object, $opt);
        if ($response->isOK()) {
            return true;
        } elseif ($response->status === 404) {
            return false;
        }
        return $response;
    }

Usage Example

Esempio n. 1
0
function file_deleteBAE($file) {
	global $_W;
	$baiduBCS = new BaiduBCS($_W['config']['bae']['ak'], $_W['config']['bae']['sk']);
	if ($file[0] == '/' && $baiduBCS->is_object_exist($_W['config']['bae']['bucket'], $file)) {
		$response = $baiduBCS->delete_object($_W['config']['bae']['bucket'], $file);
	}
	return TRUE;
}
All Usage Examples Of BaiduBCS::is_object_exist