The file entity destination plugin for migration was unnecessarily complex (examining source configuration, handling copying/moving of files, etc.) and fragile, being particularly difficult to use for migration scenarios other than full core upgrades. The configuration and functionality necessary for performing file migrations has been reorganized so that source, process, and destination plugins each perform only work appropriate to their respective stages.
To accomplish this, two new process plugins have been added, performing tasks that had formerly been embedded within the entity:file destination plugin:
- file_copy: Accepts a two-value array, the first value being the path to a file to be copied, and the second being the path to copy the file to.
- urlencode: Encodes the components of the source value (presumed to be a URL) according to RFC-3986.
Before
...
source:
plugin: d7_file
process:
uri: uri
destination:
plugin: entity:file
source_path_property: filepath
source_base_path: /var/data/root-of-source-files/
urlencode: true
After
source:
plugin: d7_file
constants:
source_base_path: /var/data/root-of-source-files/
process:
# Construct the full path of each source file from the provided directory and the individual path,
# encoding it according to RFC-3986.
source_full_path:
-
plugin: concat
delimiter: /
source:
- constants/source_base_path
- filepath
-
plugin: urlencode
# Copy the file to the desired Drupal destination (usually public://...).
uri:
plugin: file_copy
source:
- '@source_full_path'
- uri
destination:
plugin: entity:file