programmatically attaching file to file media I am trying to programmatically attach a file to a node, using the media module now included in core as of Drupal 8.5.0. 

I wrote this drush script to stub out the creation of a new file media content piece. 

&lt;?php

use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\media\entity\Media;

$file = file_save_data(uniqid(), 'public://test' . uniqid() . '.txt');

$drupalMedia = Media::create([
  'bundle' =&gt; 'file',
  'uid' =&gt; '0',
  'file' =&gt; [
    'target_id' =&gt; $file-&gt;id(),
  ],
]);

$drupalMedia-&gt;setName(uniqid())
  -&gt;setPublished(TRUE)
  -&gt;save();


When I navigate to the site's media at admin/content/media, I see my media listed: 



But when I edit the piece of media, my text file is not attached to it:



There are no error messages in watchdog. 

What am I missing? What do I need to do to attach the file to the media?
The key for file needed to be field_media_file instead of file.