title: Gaufrette and Symfony 2: There is no filesystem defined for the "images" domain
body: <p>I'm using Symfony3 with the <a href="https://github.com/KnpLabs/KnpGaufretteBundle/blob/master/DependencyInjection/MainConfiguration.php" rel="nofollow">KnpGaufretteBundle</a> to connect to an Amazon S3 bucket with the AWS S3 method outlined on their Github Readme</p>
  
  <pre><code>aws_s3_adapter:
    key:        "%aws_key%"
    secret_key: "%aws_secret%"
    region:     "%aws_region%"
  
  knp_gaufrette:
    adapters:
      images:
          aws_s3:
              service_id: 'aws_s3_adapter.client'
              bucket_name: '%aws_bucket%'
              options:
                  directory: 'images'
    filesystems:
      images:
          adapter: images
          alias:   images_fs
  </code></pre>
  
  <p>I also have a service defined that I want to use to manage this filesystem (and others) with.</p>
  
  <p>Definition:</p>
  
  <pre><code>services:
    test.image_manager:
      class: TestBundle\Filesystem\FileManager
      arguments: 
        filesystem: "@images_fs"
        filesystem_name: "images"
        mimetypes: ["image/jpeg", "image/png", "image/gif"]
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>&lt;?php
  
  namespace TestBundle\Filesystem;
  
  use Symfony\Component\HttpFoundation\File\UploadedFile;
  use Symfony\Component\HttpFoundation\BinaryFileResponse;
  
  use Gaufrette\Filesystem;
  use Gaufrette\StreamWrapper;
  
  class FileManager
  {
      private $allowedMimeTypes;
  
      private $filesystem;
  
      private $filsystem_name;
  
      public function __construct(Filesystem $filesystem, $filesystem_name, $mimetypes = array())
      {
          $this-&gt;filesystem = $filesystem;
          $this-&gt;filesystem_name = $filesystem_name;
          $this-&gt;allowedMimeTypes = $mimetypes;
      }
  
      public function upload(UploadedFile $file, $filename)
      {
          // Check if the file's mime type is in the list of allowed mime types.
          if (!in_array($file-&gt;getClientMimeType(), $this-&gt;allowedMimeTypes)) {
              throw new \InvalidArgumentException(sprintf('Files of type %s are not allowed.', $file-&gt;getClientMimeType()));
          }
  
          $adapter = $this-&gt;filesystem-&gt;getAdapter();
          $adapter-&gt;setMetadata($filename, array('contentType' =&gt; $file-&gt;getClientMimeType()));
          return $adapter-&gt;write($filename, file_get_contents($file-&gt;getPathname()));
      }
  
      public function fetch( $filename )
      {
          if( ! $this-&gt;filesystem-&gt;has( $filename ) )
          {
              return false;
          }
  
  
          /* -- PROBLEM -- */
  
          StreamWrapper::register();
          return new BinaryFileResponse( "gaufrette://{$this-&gt;filesystem_name}/{$filename}" );
  
          /* -- PROBLEM -- */
  
      }
  
      public function delete( $filename )
      {
          if( ! $this-&gt;filesystem-&gt;has( $filename ) )
          {
              return false;
          }
          return $this-&gt;filesystem-&gt;delete( $filename );
      }
  }
  </code></pre>
  
  <p>I'm able to upload successfully to the bucket using the upload function, telling me that the filesystem exists and is working properly.</p>
  
  <p>I am not, however, able to use the Gaufrette\StreamWrapper to serve the file using a BinaryFileResponse as it says I should do. Instead it is giving me the error that I put in the title: <code>There is no filesystem defined for the "images" domain.</code></p>
  
  <p>The filesystem definitely exists, as I'm using it to upload the images. Any clues as to what the problem might be that's preventing me from using that filesystem would be very helpful. The Gaufrette documentation is really sparse online so far as I've found, but I'm going to keep digging.</p>