# 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. ## Node action The module also provides **Move associated unpublished media files to private storage** as a node action. For each selected node it finds media whose `field_media_of` references that node and applies the existing `media_file_privacy_move_unpublished_private` media action to each accessible media item. The module also provides **Move associated published media files to public storage** as a node action. For each selected node it finds media whose `field_media_of` references that node and applies the existing `media_file_privacy_move_published_public` media action to each accessible media item.