1

I'm trying to import images, but why does migrate_tools swear on my yml file when I try to migrate.

id: migrate__articles_teaser_images1
label: 'Migration teaser images of article'
migration_tags: null
migration_group: test

source:
  plugin: migrate__json
  module: migrate
  path: assets/articles.json
  columns:
    0:
      key: id
      label: 'Id'
    1:
      key: photo_name
      label: 'Photo name'
  key: id
  constants:
    file_source_uri: public://import/program
    file_dest_uri: 'public://program/image'

process:
  file_source:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/file_source_uri
        - photo_name
    -
      plugin: urlencode
  file_dest:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/file_dest_uri
        - photo_name
    -
      plugin: urlencode
  filename: photo_name
  uri:
    plugin: file_copy
    source:
      - '@file_source'
      - '@file_dest'

destination:
  plugin: entity:file

I do not quite understand how the URI is organized and why need to write "public: // ...", but at the root of my site there is an import / program folder that contains images (to which I refer from sources) for later copying .

My json file:

[
  {
    "id": 523,
    "title": "Love Is Strange",
    "photo_name": "1.png",
    "author_id": 3,
    "alias": "love_is_strange",
    "categories_ids": [
      {
        "category_id": 2
      },
      {
        "category_id": 1
      }
    ],
    "teaser_text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
  }
]

That is, there is a file 1.png in my import/program folder. But still my code does not work, help me find the error.

  • The public:// prefix refers to the public file storage / uploaded files directory of Drupal, usually something like /web/sites/default/files/.... This is not the document root of your webserver. – Hudri Sep 3 '18 at 17:06
  • @Hudri, thank you so much. Now everything became clear – Vladislav Sep 4 '18 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.