On occasion, there is a need for a subset of files to be present on the lower environments for testing purposes. It would be great to have a VBO action for file and media entities, which would allow to selectively download managed files.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

euk created an issue. See original summary.

euk’s picture

Status: Active » Needs review

Ok. I added a MR for the 3.x version. Here is what it does:

The Stage File Proxy: Download files action downloads selected managed files from the configured Stage File Proxy origin. It can be applied to File entities and to Media entities whose configured source field references managed files. Files using a scheme other than public:// cannot be downloaded by the action.

The action is a Drupal core action and does not require Views Bulk Operations. When Views Bulk Operations is installed, the action can be added to File or Media views so that an administrator can download only the selected entities.

The action provides the following options:

  • Overwrite existing files : Download a file even when it already exists in the local public file system. When disabled, existing files are skipped.
  • Enable debug logging: Add informational DEBUG entries for selected Media entities. File outcomes are logged whether or not this option is enabled. Action messages are written to the stage_file_proxy log channel.

For logging, file-level entries use the following severities:

  • INFO (6): The file was downloaded successfully, including when an existing file was overwritten.
  • NOTICE (5): The file was skipped because it already exists locally and Overwrite existing files is disabled.
  • WARNING (4): The file is unavailable at the origin or cannot be downloaded, for example because of an HTTP, connection, incomplete-download, or unsupported file-system scheme error.
  • ERROR (3): The downloaded file cannot be saved locally, for example because the destination directory cannot be prepared or written to.

When Enable debug logging is selected, the action also writes DEBUG (7) entries for Media entities. These entries are informational and describe cases such as a Media entity having no managed source file and the final per-Media download summary. The debug option does not suppress the file-level entries listed above.

NOTE: The logging levels were update for the download manager as well, to be in sync with the action.

smustgrave’s picture

Status: Needs review » Needs work

Just an fyi when AI is used it needs to be disclosed https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett...

No issue doing that but just need to mention.

MR seems to be full of little AI only stuff that won't fully be needed. Will have to sit down in a week or so and find them all.

Going to need test coverage

euk’s picture

Ah, right! I was in a hurry, looked over but did not fully clean it up. Let me work on that and make it human.

smustgrave’s picture

Much appreciated. I should have also started with +1 to the feature. Can see others using it

euk’s picture

No worries. I will review, cleanup and disclose what is needed.