How create a file type field in custom entity programmatically? This is how i create my field in my Entity content :

  $fields['fid'] = BaseFieldDefinition::create('file')
      -&gt;setLabel(t('Photo'))
      -&gt;setRequired(false)
      -&gt;setDescription(t('Product image'))
      -&gt;setSettings(array(
          'upload_location' =&gt; 'public://produits/',
          'upload_validators' =&gt; array(
              'file_validate_extensions' =&gt; array('png jpg jpeg'),
          ),
      ))
      -&gt;setDisplayOptions('view', array(
          'label' =&gt; 'above',
          'type' =&gt; 'file',
          'weight' =&gt; -3,
      ))
      -&gt;setDisplayOptions('form', array(
          'type' =&gt; 'file',
          'settings' =&gt; array(
              'upload_location' =&gt; 'public://produits/',
              'upload_validators' =&gt; array(
                  'file_validate_extensions' =&gt; array('png jpg jpeg'),
              ),
          ),
          'weight' =&gt; -1,
      ))

      -&gt;setDisplayConfigurable('form', TRUE)
      -&gt;setDisplayConfigurable('view', TRUE);


The field is create in my form but when i try to upload a file :

I got this error : 


  Only '.txt' extension is authorized


Edit 1 :

In fact my settings are never read, after upload a .txt for test, the directory is wrong.

Any idea about this ?
The only way i have found is to move this param into the Entityform :

  $form['fid'] = array(
      '#type' =&gt; 'managed_file',
      '#upload_location' =&gt; 'public://produits/',
      '#default_value' =&gt; $entity-&gt;get('fid')-&gt;value,
      '#description' =&gt; t('png jpge jpg'),
      '#upload_validators' =&gt; array(
          'file_validate_extensions' =&gt; array('png jpg jpeg'),
      )
  );