Skip to content

Instantly share code, notes, and snippets.

@weaver299
Created February 14, 2019 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaver299/f241288a9a67b9dbdf711c347e7d7d77 to your computer and use it in GitHub Desktop.
Save weaver299/f241288a9a67b9dbdf711c347e7d7d77 to your computer and use it in GitHub Desktop.
id: media_files
label: Migrate managed files
description: Migrate managed files
migration_group: media
migration_tags:
- Drupal 7
- Content
migration_dependencies:
required:
- users
source:
plugin: d7_file
scheme: public
constants:
# The tool configuring this migration must set source_base_path. It
# represents the fully qualified path relative to which URIs in the files
# table are specified, and must end with a /. See source_full_path
# configuration in this migration's process pipeline as an example.
source_base_path: 'sites/default/files/legacy'
process:
# If you are using this file to build a custom migration consider removing
# the fid field to allow incremental migrations.
fid: fid
filename: filename
source_full_path:
-
plugin: concat
delimiter: /
source:
- constants/source_base_path
- filepath
-
plugin: urlencode
uri:
plugin: file_copy # skip_youtube_files isn't needed because of 'scheme' source plugin option
source:
- '@source_full_path'
- uri
# -
# plugin: skip_youtube_files
# source:
# - '@source_full_path'
# - uri
# -
# plugin: file_copy
# #move: true
filemime: filemime
# No need to migrate filesize, it is computed when file entities are saved.
# filesize: filesize
status: status
# Drupal 7 didn't keep track of the file's creation or update time -- all it
# had was the vague "timestamp" column. So we'll use it for both.
created: timestamp
changed: timestamp
uid: uid
destination:
plugin: entity:file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment