Gaufrette\Adapter\AwsS3::exists PHP Method

exists() public method

public exists ( $key )
    public function exists($key)
    {
        return $this->service->doesObjectExist($this->bucket, $this->computePath($key));
    }

Usage Example

 public function testChecksForObjectExistenceWithDirectory()
 {
     $mock = new MockPlugin(array(new Response(200)));
     $client = $this->getClient();
     $client->addSubscriber($mock);
     $adapter = new AwsS3($client, 'bucket', array('directory' => 'bar'));
     $this->assertTrue($adapter->exists('foo'));
     $requests = $mock->getReceivedRequests();
     $this->assertEquals('bucket.s3.amazonaws.com', $requests[0]->getHost());
     $this->assertEquals('HEAD', $requests[0]->getMethod());
     $this->assertEquals('/bar/foo', $requests[0]->getResource());
 }