Problem/Motivation

When migrating a site it is common for file configuration to be modified so that files are stored in a more structured path, rather than everything stored in the single public:// directory.

Proposed resolution

Provide an option for the FileCopy plugin to allow the destination path to be modified based upon details from the source file.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

damienmckenna created an issue. See original summary.

benjifisher’s picture

Status: Active » Postponed (maintainer needs more info)

You can already do something like the following:

process:
  destination_uri:
    - plugin: concat
      delimiter: '/'
      source:
        - constants/scheme # public:/
        - constants/base   # migrated_files
        - source_date      # 2018-01
        - source_filename  # myfile.txt
  path_to_file:
    - plugin: file_copy
      source:
        - some_source_field
        - '@destination_uri'

That should copy the source file to public://migrated_files/2018-01/myfile.txt. The source_date could be supplied directly by the source plugin or it could be the result of the format_date plugin.

Can you be more specific about what you want to do that is not already possible? Maybe give an example of the migration YAML that you would like to use. It seems to me that, as my example shows, you can already set the destination path to anything you want, including something based on information from the source.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.