Image

content_entity
plugin only works if migrating site within an existing Drupal 8/9 site. If you need to use an external database from a D8/D9 site, you'll need the https://www.drupal.org/project/migrate_drupal_d8 module
Here's an example of migrating files (prior to migrating media items)
id: im_files
label: Migrate public files from legacy D9 to new D9
langcode: en
status: true
dependencies: { }
migration_tags:
- files
source:
plugin: d8_entity
scheme: public
key: migrate
entity_type: file
constants:
SOURCE_DOMAIN: 'https://legacy-site.dev'
DRUPAL_FILE_DIRECTORY: 'public://migrated_files/'
process:
filename:
-
plugin: get
source: filename
source_public_absolute_path:
-
plugin: str_replace
source: uri
search: 'public://'
replace: 'sites/default/files/'
source_full_path:
-
plugin: concat
delimiter: /
source:
- constants/SOURCE_DOMAIN
- '@source_public_absolute_path'
-
plugin: urlencode
destination_filename:
- plugin: callback
callable: basename
source: filename
- plugin: skip_on_empty
method: row
message: 'Cannot import empty filename.'
destination_path:
-
plugin: concat
source:
- constants/DRUPAL_FILE_DIRECTORY
- '@destination_filename'
-
plugin: urlencode
uri:
-
plugin: skip_on_empty
method: row
source: '@source_full_path'
message: 'File field_name does not exist'
-
plugin: file_copy
source:
- '@source_full_path'
- '@destination_path'
filemime:
-
plugin: get
source: filemime
filesize:
-
plugin: get
source: filesize
status:
-
plugin: get
source: status
created:
-
plugin: get
source: timestamp
changed:
-
plugin: get
source: timestamp
uid:
-
plugin: default_value
default_value: 1
destination:
plugin: 'entity:file'
migration_dependencies: null