id: agaric_file
migration_group: agaric
label: Public files
source:
  plugin: d7_file
  scheme: public
process:
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - filepath
    -
      plugin: str_replace
      search: 'sites/default/files/'
      # The old files must be located at this path:
      replace: 'sites/default/import/'
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - '@source_full_path'
      - uri
  filemime: filemime
  status: status
  created: timestamp
  changed: timestamp
  uid:
    -
      plugin: migration_lookup
      migration: agaric_user
      source: uid
      no_stub: true
    -
      # If the user id does not exists then migrate it as anonymous.
      plugin: default_value
      default_value: 0
destination:
  plugin: entity:file
migration_dependencies:
  required:
    - agaric_user
