This project is not covered by Drupal’s security advisory policy.
The purpose of this module is to assist with migrating files while needing to work with their extensions and mime types.
A primary use case is when you are migrating files and media entities, but during the migration it fails because you imported a file without an extension (but having a valid mime type e.g. image/png). Using this process plugin, the mime type of the downloaded file will automatically be detected and the file will be renamed to have an appropriate extension based on that mime type.
An example from the process section of a file entity migration:
...
process:
uri:
- plugin: download
source:
- source_url
- '@destination_full_path'
file_exists: 'use existing'
- plugin: append_extension_mime_type
...
Say after the download plugin has processed, it has placed a file at public://2021-01/my-image-file-with-no-extension. The append_extension_mime_type process plugin will detect the mime type of the file as image/png, look up a valid extension for that mime type, and rename/move the file to public://2021-01/my-image-file-with-no-extension.png.
This process plugin will throw a MigrateSkipRowException if a valid mime type cannot be determined for the file or, if the mime type could be determined, if a valid extension for that mime type could not be determined either.
If you see room for enhancements and support for more use cases, I am gladly accepting contributions. I sparsely do migration work, so this module will be minimally maintained otherwise.
Project information
Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.- Project categories: Import and export
- Ecosystem: Migrate
- Created by lpeabody on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
