src/Driver/Cores/Drupal8.php
protected function saveFile($source) {
    $name = basename($source);
    $path = realpath(DRUPAL_ROOT . '/' . $source);
    $uri = file_unmanaged_copy($path, 'public://' . $name, FILE_EXISTS_REPLACE);
    $file = File::create(['uri' => $uri]);
    $file->save();
    return $file;
  }
protected function saveFile($source) {
    $name = basename($source);
    $path = realpath(DRUPAL_ROOT . '/' . $source);
    $uri = file_unmanaged_copy($path, 'public://' . $name, FILE_EXISTS_REPLACE);
    $file = File::create(['uri' => $uri]);
    $file->save();
    return $file;
  }
protected function saveFile ( $ source ) { $ name = basename ( $ source ) ; $ path = realpath ( DRUPAL_ROOT . '/' . $ source ) ; $ uri = file_unmanaged_copy ( $ path , 'public://' . $ name , FILE_EXISTS_REPLACE ) ; $ file = File :: create ( [ 'uri' => $ uri ] ) ; $ file -> save ( ) ; return $ file ; }
Save a file and return its id.

@param string $source
Source path relative to Drupal installation root.

@return \Drupal\Core\Entity\EntityInterface
Saved file object.
Save a file and return its id .