0

I have a directory with PDF files and I have 45 nodes of content type Download. I have to migrate each PDF file to specific node. All PDF file names I read from a CSV. Before these PDF files, I had to migrate title (drupal default field) , external title and a checkbox field to each node. I did it successfully, but migrating PDF files is I guess different and a lot more difficult.

Here is my code for migrating PDF files

id: program_files
label: Migrating files for Download content type.
migration_tags:
  - file
source:
  plugin: csv
  path: 'modules/custom/csv_migration/sources/downloads.csv'
  header_row_count: 1
  ids: [constants/file_source_uri]
  keys:
    - PLACEMENTPATH
  fields:
    0:
      name: field_document_file
      label: 'Download file'
  constants:
    file_source_uri: [public://import/program]
    file_dest_uri: ['public://download/files']
destination:
  plugin: 'entity:file'
process:
  file_source:
    -
      plugin: concat
      delimiter: /
      source: [constants/file_source_uri, PLACEMENTPATH]
  file_dest:
    -
      plugin: concat
      delimiter: /
      source: [constants/file_dest_uri, PLACEMENTPATH]
  filename: PLACEMENTPATH
  uri:
    -
      plugin: file_copy
      source:
        - '@file_source'
        - '@file_dest'

Once I run command drush ms it displays me migration id (program_files), but after that when I run drush mim program_files, it throws the error like this.

In Connection.php line 744:
                                                                                            
  Placeholders must have a trailing [] if they are to be expanded with an array of values.  

The thing I notice once I start drush mim program_files is that directory download is created in sites/default/files, since I defined that in YML, but no files are transfered.

What am I doing wrong? Please, help.

2
  • 4
    I hate to say it, but for just 45 files, it's probably faster to manually create the nodes and upload the PDFs than to troubleshoot a migration. Jan 17, 2021 at 13:59
  • +1 @PatrickKenny , have been trying to solve issue with migration from the past two weeks drupal.stackexchange.com/questions/299395 still not able to resolve it. Jan 17, 2021 at 14:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.