title: Unable to check if Amazon s3 bucket exists using Gaufrette with Symfony2
body: <p>Getting this error when trying to upload a file to my bucket using VichUploader, Gaufrette and the AWS SDK v2 on a Symfony2 web app. Sounds like a problem with the API calls. It's giving me a Denied Access (Error 500 Interal Server Error) Can anybody help me here ?</p>
  
  <p>Config :</p>
  
  <pre><code>knp_gaufrette:
      stream_wrapper: ~
  
      adapters:
          local_adapter:
              local:
                  directory: %kernel.root_dir%/../web/uploads/img
          aws_s3_adapter:
              aws_s3:
                  service_id: 'et.aws_s3'
                  bucket_name: mybucket
                  options:
                      create: false
                      directory: 'uploads'
  
      filesystems:
          aws_s3_fs:
              adapter:    aws_s3_adapter
          local_fs:
              adapter:    local_adapter
  
  vich_uploader:
      db_driver: orm
      storage: gaufrette
      mappings:
          image:
              uri_prefix: https://s3.amazonaws.com/mybucket # you'll need this set to use the Vich URL generator
              upload_destination: aws_s3_fs
              namer: vich_uploader.namer_uniqid
              delete_on_remove: true
              delete_on_update: true
              inject_on_load:   true
  </code></pre>
  
  <p>Services :</p>
  
  <pre><code>services:
      et.aws_s3:
          class: Aws\S3\S3Client #Gaufrette\Adapter\AwsS3
          factory_class: Aws\S3\S3Client
          factory_method: factory
          arguments:
              -
                  key: key
                  secret: key
                  region: us-west-2
  </code></pre>
  
  <p>Stack trace: </p>
  
  <pre><code>[1] Aws\S3\Exception\AccessDeniedException: Access Denied
      at n/a
          in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\NamespaceExceptionFactory.php line 91
  
      at Aws\Common\Exception\NamespaceExceptionFactory-&gt;createException('Aws\S3\Exception\AccessDeniedException', object(EntityEnclosingRequest), object(Response), array('code' =&gt; 'AccessDenied', 'message' =&gt; 'Access Denied', 'type' =&gt; 'client', 'request_id' =&gt; 'B4966F7BBECF30F3', 'parsed' =&gt; object(SimpleXMLElement)))
          in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\NamespaceExceptionFactory.php line 76
  
      at Aws\Common\Exception\NamespaceExceptionFactory-&gt;fromResponse(object(EntityEnclosingRequest), object(Response))
          in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\ExceptionListener.php line 55
  
      at Aws\Common\Exception\ExceptionListener-&gt;onRequestError(object(Event), 'request.error', object(EventDispatcher))
          in  line 
  
      at call_user_func(array(object(ExceptionListener), 'onRequestError'), object(Event), 'request.error', object(EventDispatcher))
          in C:\xampp2\htdocs\WebProject\app\cache\dev\classes.php line 1790
  
      at Symfony\Component\EventDispatcher\EventDispatcher-&gt;doDispatch(array(array(object(ExceptionListener), 'onRequestError'), array('Guzzle\Http\Message\Request', 'onRequestError')), 'request.error', object(Event))
          in C:\xampp2\htdocs\WebProject\app\cache\dev\classes.php line 1723
  
      at Symfony\Component\EventDispatcher\EventDispatcher-&gt;dispatch('request.error', object(Event))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Message\Request.php line 589
  
      at Guzzle\Http\Message\Request-&gt;processResponse(array('handle' =&gt; object(CurlHandle)))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Message\Request.php line 378
  
      at Guzzle\Http\Message\Request-&gt;setState('complete', array('handle' =&gt; object(CurlHandle)))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Message\EntityEnclosingRequest.php line 49
  
      at Guzzle\Http\Message\EntityEnclosingRequest-&gt;setState('complete', array('handle' =&gt; object(CurlHandle)))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 303
  
      at Guzzle\Http\Curl\CurlMulti-&gt;processResponse(object(EntityEnclosingRequest), object(CurlHandle), array('msg' =&gt; '1', 'result' =&gt; '0', 'handle' =&gt; 'Resource id #2420'))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 257
  
      at Guzzle\Http\Curl\CurlMulti-&gt;processMessages()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 240
  
      at Guzzle\Http\Curl\CurlMulti-&gt;executeHandles()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 224
  
      at Guzzle\Http\Curl\CurlMulti-&gt;perform()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMulti.php line 111
  
      at Guzzle\Http\Curl\CurlMulti-&gt;send()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Curl\CurlMultiProxy.php line 94
  
      at Guzzle\Http\Curl\CurlMultiProxy-&gt;send()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Http\Client.php line 284
  
      at Guzzle\Http\Client-&gt;send(object(EntityEnclosingRequest))
          in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Client\AbstractClient.php line 256
  
      at Aws\Common\Client\AbstractClient-&gt;send(object(EntityEnclosingRequest))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Client.php line 136
  
      at Guzzle\Service\Client-&gt;execute(object(S3Command))
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Command\AbstractCommand.php line 153
  
      at Guzzle\Service\Command\AbstractCommand-&gt;execute()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Command\AbstractCommand.php line 189
  
      at Guzzle\Service\Command\AbstractCommand-&gt;getResult()
          in C:\xampp2\htdocs\WebProject\vendor\guzzle\guzzle\src\Guzzle\Service\Client.php line 76
  
      at Guzzle\Service\Client-&gt;__call('CreateBucket', array(array('Bucket' =&gt; 'eventori', 'LocationConstraint' =&gt; 'us-west-2')))
          in C:\xampp2\htdocs\WebProject\vendor\aws\aws-sdk-php\src\Aws\Common\Client\AbstractClient.php line 104
  
      at Aws\Common\Client\AbstractClient-&gt;__call('createBucket', array(array('Bucket' =&gt; 'eventori', 'LocationConstraint' =&gt; 'us-west-2')))
          in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Adapter\AwsS3.php line 254
  
      at Aws\S3\S3Client-&gt;createBucket(array('Bucket' =&gt; 'eventori', 'LocationConstraint' =&gt; 'us-west-2'))
          in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Adapter\AwsS3.php line 254
  
      at Gaufrette\Adapter\AwsS3-&gt;ensureBucketExists()
          in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Adapter\AwsS3.php line 125
  
      at Gaufrette\Adapter\AwsS3-&gt;write('5535ad181397d.png', '')
          in C:\xampp2\htdocs\WebProject\vendor\knplabs\gaufrette\src\Gaufrette\Filesystem.php line 122
  
      at Gaufrette\Filesystem-&gt;write('5535ad181397d.png', '', true)
          in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\Storage\GaufretteStorage.php line 56
  
      at Vich\UploaderBundle\Storage\GaufretteStorage-&gt;doUpload(object(PropertyMapping), object(UploadedFile), '', '5535ad181397d.png')
          in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\Storage\AbstractStorage.php line 67
  
      at Vich\UploaderBundle\Storage\AbstractStorage-&gt;upload(object(Image), object(PropertyMapping))
          in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\Handler\UploadHandler.php line 64
  
      at Vich\UploaderBundle\Handler\UploadHandler-&gt;upload(object(Image), 'imageFile')
          in C:\xampp2\htdocs\WebProject\app\cache\dev\appDevDebugProjectContainer.php line 9126
  
      at VichUploaderBundleHandlerUploadHandler_00000000534e394600000000143551d5-&gt;upload(object(Image), 'imageFile')
          in C:\xampp2\htdocs\WebProject\vendor\vich\uploader-bundle\EventListener\Doctrine\UploadListener.php line 41
  
      at Vich\UploaderBundle\EventListener\Doctrine\UploadListener-&gt;prePersist(object(LifecycleEventArgs))
          in C:\xampp2\htdocs\WebProject\vendor\symfony\symfony\src\Symfony\Bridge\Doctrine\ContainerAwareEventManager.php line 63
  
      at Symfony\Bridge\Doctrine\ContainerAwareEventManager-&gt;dispatchEvent('prePersist', object(LifecycleEventArgs))
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\Event\ListenersInvoker.php line 117
  
      at Doctrine\ORM\Event\ListenersInvoker-&gt;invoke(object(ClassMetadata), 'prePersist', object(Image), object(LifecycleEventArgs), '4')
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 896
  
      at Doctrine\ORM\UnitOfWork-&gt;persistNew(object(ClassMetadata), object(Image))
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 1683
  
      at Doctrine\ORM\UnitOfWork-&gt;doPersist(object(Image), array('00000000534e3b0d00000000143551d5' =&gt; object(Event), '00000000534e272c00000000143551d5' =&gt; object(User), '00000000534e3df700000000143551d5' =&gt; object(Image)))
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 2229
  
      at Doctrine\ORM\UnitOfWork-&gt;cascadePersist(object(Event), array('00000000534e3b0d00000000143551d5' =&gt; object(Event), '00000000534e272c00000000143551d5' =&gt; object(User), '00000000534e3df700000000143551d5' =&gt; object(Image)))
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 1702
  
      at Doctrine\ORM\UnitOfWork-&gt;doPersist(object(Event), array('00000000534e3b0d00000000143551d5' =&gt; object(Event), '00000000534e272c00000000143551d5' =&gt; object(User), '00000000534e3df700000000143551d5' =&gt; object(Image)))
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php line 1639
  
      at Doctrine\ORM\UnitOfWork-&gt;persist(object(Event))
          in C:\xampp2\htdocs\WebProject\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php line 579
  
      at Doctrine\ORM\EntityManager-&gt;persist(object(Event))
          in C:\xampp2\htdocs\WebProject\src\ET\CoreBundle\Controller\EventController.php line 63
  
      at ET\CoreBundle\Controller\EventController-&gt;createAction(object(Request))
          in  line 
  
      at call_user_func_array(array(object(EventController), 'createAction'), array(object(Request)))
          in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 3029
  
      at Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(object(Request), '1')
          in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 2991
  
      at Symfony\Component\HttpKernel\HttpKernel-&gt;handle(object(Request), '1', true)
          in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 3140
  
      at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel-&gt;handle(object(Request), '1', true)
          in C:\xampp2\htdocs\WebProject\app\bootstrap.php.cache line 2384
  
      at Symfony\Component\HttpKernel\Kernel-&gt;handle(object(Request))
          in C:\xampp2\htdocs\WebProject\web\app_dev.php line 28
  </code></pre>