title: SonataMediaBundle: How to add svg file extension
body: <p>I need to add <strong>.svg</strong> file extension to my configuration.</p>
  
  <p>At the moment in my project I have other extensions as (pdf, images)</p>
  
  <p>I made the following changes</p>
  
  <ol>
  <li>Added a new svg_file to the <strong>context</strong></li>
  <li>Added the file provider (In the end of configuration file)</li>
  <li>Added the svg in <strong>allowed_extensions</strong></li>
  <li>Added the image/svg+xml in <strong>allowed_mime_types</strong></li>
  </ol>
  
  <p>Now, I can upload the svg file but the problem is that the user can upload other <strong>file extensions</strong> for example pdf etc..</p>
  
  <p>How can avoid it? Or find a proper way for the form validation?</p>
  
  <p>The Sonata documentations:</p>
  
  <ul>
  <li><p><a href="https://sonata-project.org/bundles/media/master/doc/reference/advanced_configuration.html" rel="nofollow">ADVANCED CONFIGURATION</a></p></li>
  <li><p><a href="https://sonata-project.org/bundles/media/master/doc/reference/media_context.html" rel="nofollow">Media context</a></p></li>
  </ul>
  
  <p>helped me, but not for the form validation.</p>
  
  <p>What I'm missing?</p>
  
  <hr>
  
  <p>I changed the follows files:</p>
  
  <pre><code>#app/config/sonata_config.yml
  
  sonata_media:
  default_context: images_file
  db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr
  contexts:
      pdf_file:
          providers:
              - sonata.media.provider.file
          formats: ~
      images_file:
          providers:
              - sonata.media.provider.image
          formats:
              1x: { width: 870 , height: 412 , quality: 80 }
              2x: { width: 1740 , height: 824 , quality: 50 }
      svg_file:
          providers:
              - sonata.media.provider.file
          formats: ~
      cdn:
          server:
            path: /uploads/media # http://media.sonata-project.org/
  
      filesystem:
          local:
             directory:  %kernel.root_dir%/../web/uploads/media
             create:     false
  
      providers:
          file:
             service:    sonata.media.provider.file
             resizer:    false
             filesystem: sonata.media.filesystem.local
             cdn:        sonata.media.cdn.server
             generator:  sonata.media.generator.default
             thumbnail:  sonata.media.thumbnail.format
             allowed_extensions: ['pdf', 'txt', 'rtf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pttx', 'odt', 'odg', 'odp', 'ods', 'odc', 'odf', 'odb', 'csv', 'xml','svg']
             allowed_mime_types: ['application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain', 'image/svg+xml']
  </code></pre>
  
  <p>Form File:</p>
  
  <pre><code>use Sonata\AdminBundle\Admin\Admin;
  class CustomAdmin extends Admin
  {
  /**
   * @param FormMapper $formMapper
   */
  protected function configureFormFields(FormMapper $formMapper)
  {
      $formMapper
          -&gt;add(
              'NormalLogo',
              'sonata_type_model_list',
              array('required' =&gt; false),
              array(
                  'link_parameters' =&gt; array('context' =&gt; 'images_file', 'provider' =&gt; 'sonata.media.provider.image'),
              )
          )
          -&gt;add(
              'SvgLogo',
              'sonata_type_model_list',
              array('required' =&gt; false),
              array(
                  'link_parameters' =&gt; array('context' =&gt; 'svg_file', 'provider' =&gt; 'sonata.media.provider.file'),
              )
          )
          -&gt;add('overriddenBy', 'sonata_type_model',
              array(
                  'empty_value' =&gt; 'Not overridden',
                  'btn_add' =&gt; false,
                  'btn_list' =&gt; false,
                  'btn_delete' =&gt; false,
                  'btn_catalogue' =&gt; false,
              )
          );
  }
  }
  </code></pre>