You are here

protected function FileBlob::putFile in Migrate Plus 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate/process/FileBlob.php \Drupal\migrate_plus\Plugin\migrate\process\FileBlob::putFile()
  2. 8.2 src/Plugin/migrate/process/FileBlob.php \Drupal\migrate_plus\Plugin\migrate\process\FileBlob::putFile()
  3. 8.4 src/Plugin/migrate/process/FileBlob.php \Drupal\migrate_plus\Plugin\migrate\process\FileBlob::putFile()

Try to save the file.

Parameters

string $destination: The destination path or URI.

string $blob: The base64 encoded file contents.

int $replace: (optional) FILE_EXISTS_REPLACE (default) or FILE_EXISTS_ERROR, depending on the configuration.

Return value

bool|string File path on success, FALSE on failure.

1 call to FileBlob::putFile()
FileBlob::transform in src/Plugin/migrate/process/FileBlob.php
Performs the associated process.

File

src/Plugin/migrate/process/FileBlob.php, line 104

Class

FileBlob
Copy a file from a blob into a file.

Namespace

Drupal\migrate_plus\Plugin\migrate\process

Code

protected function putFile($destination, $blob, $replace = FILE_EXISTS_REPLACE) {
  if ($path = file_destination($destination, $replace)) {
    if (file_put_contents($path, $blob)) {
      return $path;
    }
    else {
      return FALSE;
    }
  }

  // File was already copied.
  return $destination;
}