Moves files between public and private file storage
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
astanley 37bedc086c initial commit 3 weeks ago
config/install initial commit 3 weeks ago
src/Plugin/Action initial commit 3 weeks ago
README.md initial commit 3 weeks ago
composer.json initial commit 3 weeks ago
media_file_privacy.info.yml initial commit 3 weeks ago

README.md

Media File Privacy

Drupal 10/11 module providing two Media actions:

  1. Move unpublished media files to private storage

    • Runs only on unpublished Media entities.
    • Moves a source file only when its URI begins with public://.
    • Example: public://2026-08/example.jpg -> private://2026-08/example.jpg.
  2. Move published media files to public storage

    • Runs only on published Media entities.
    • Moves a source file only when its URI begins with private://.
    • Example: private://2026-08/example.jpg -> public://2026-08/example.jpg.

Installation

Place the module at:

web/modules/custom/media_file_privacy

Enable it:

drush en media_file_privacy -y
drush cr

The actions should then be available to Media Views Bulk Operations / the standard Views bulk form, depending on the View configuration.

Collision handling

If a file already exists at the destination URI, the action logs an error and does not overwrite or rename either file. Errors are written to the media_file_privacy log channel.

Private file system

Drupal must have a working private file path configured, for example in settings.php:

$settings['file_private_path'] = '/var/www/site-files/private';

The directory must be writable by the web/PHP user.