From e4f64d9be42d782639c0c8c6d074a51fefbddfda Mon Sep 17 00:00:00 2001 From: astanley Date: Mon, 2 Jun 2025 18:58:57 +0000 Subject: [PATCH] Read streams without constructor --- src/Controller/InstructionsController.php | 16 ++++++++-------- src/Form/CreateMediaFromFileForm.php | 12 +++++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Controller/InstructionsController.php b/src/Controller/InstructionsController.php index e22ae5a..e36705a 100644 --- a/src/Controller/InstructionsController.php +++ b/src/Controller/InstructionsController.php @@ -14,24 +14,24 @@ class InstructionsController extends ControllerBase { */ public function modal() { $html = " -

Upload your files to the server. If your files follow the naming convention {nid}_filename (where {nid} is the Node ID - of the target node), the created media will automatically associate with that node. e.g. 35_myfile.tif - will create a media associated with node 35. If the files do not use this naming convention, the media will still be created, +

Upload your files to the server. If your files follow the naming convention {nid}_filename (where {nid} is the Node ID + of the target node), the created media will automatically associate with that node. e.g. 35_myfile.tif + will create a media associated with node 35. If the files do not use this naming convention, the media will still be created, but will have to be associated manually to a node through the UI.

-

If you choose Already in place, unmanaged files in the destination folder will be now be managed +

If you choose Already in place, unmanaged files in the destination folder will be now be managed by Drupal, and those files will be used to create media. This is the fastest way to ingest very large files.

-

The source directory holds files to be ingested. The source directory must be identified by the full +

The source directory holds files to be ingested. The source directory must be identified by the full server path e.g. /var/www/upload_folder.

-

The destination directory will exist within the Drupal file system. The path is relative, and the folder will be created within the file system +

The destination directory will exist within the Drupal file system. The path is relative, and the folder will be created within the file system if it does not already exist. The user must have permissions to create folders and write files in the selected file system.

The filesystem is defined within the Media Types definitions. The uploaded files will be stored - in that system unless another file system is selected. + in that system unless another file system is selected. n.b. If your installation only uses one file system this choice is irrelevant

File ownership is normally www-data:www-data on Apache systems and nginx:nginx for a Docker based Islandora installation. The default value is normally fine, but confirm with your systems administrator - if you are unsure. n.b. If your installation only uses one file system this choice is irrelevant. + if you are unsure.

"; return [ '#type' => 'markup', diff --git a/src/Form/CreateMediaFromFileForm.php b/src/Form/CreateMediaFromFileForm.php index e6c8013..b61167d 100644 --- a/src/Form/CreateMediaFromFileForm.php +++ b/src/Form/CreateMediaFromFileForm.php @@ -107,18 +107,20 @@ final class CreateMediaFromFileForm extends FormBase { $file_system_options = []; $file_system_options['default'] = $this->t("File system defined in media type"); - $unwanted = ['temporary', 'assets']; + $unwanted = ['temporary', 'assets', 'temporary', 'library-definitions', 'asset', 'php-file']; foreach ($wrappers as $scheme => $wrapper_info) { if (in_array($scheme, $unwanted)) { continue; } - $class = $wrapper_info['class']; - if (is_a($class, StreamWrapperInterface::class, TRUE) && class_exists($class)) { - $instance = new $class(); - $instance->setUri($scheme . '://'); + try { + $instance = $this->streamWrapperManager->getViaScheme($scheme); $file_system_options[$scheme] = $instance->getName() ?: $scheme; } + catch (\Exception $e) { + // Log or ignore missing/broken stream wrapper + } + } $media_types = $this->entityTypeManager->getStorage('media_type')->loadMultiple();