You are here

public function DrupalBrowserUploadDestination::getFile in Backup and Migrate 8.4

Get a file object representing the file with the given ID from the destination. This file item will not necessarily be readable nor will it have extended metadata loaded. Use loadForReading and loadFileMetadata to get those.

@TODO: Decide if extended metadata should ALWAYS be loaded here.

Parameters

string $id The unique identifier for the file. Usually the filename.:

Return value

\BackupMigrate\Core\File\BackupFileInterface The file if it exists or NULL if it doesn't

Overrides ReadableDestinationInterface::getFile

File

src/Destination/DrupalBrowserUploadDestination.php, line 20

Class

DrupalBrowserUploadDestination
Class BrowserUploadDestination.

Namespace

BackupMigrate\Drupal\Destination

Code

public function getFile($id) {
  $file_upload = \Drupal::request()->files
    ->get("files", NULL, TRUE)[$id];

  // Make sure there's an upload to process.
  if (!empty($file_upload)) {
    $out = new ReadableStreamBackupFile($file_upload
      ->getRealPath());
    $out
      ->setFullName($file_upload
      ->getClientOriginalName());
    return $out;
  }
}