Browse Source

Read streams without constructor

main
astanley 7 months ago
parent
commit
e4f64d9be4
  1. 16
      src/Controller/InstructionsController.php
  2. 12
      src/Form/CreateMediaFromFileForm.php

16
src/Controller/InstructionsController.php

@ -14,24 +14,24 @@ class InstructionsController extends ControllerBase {
*/
public function modal() {
$html = "
<p>Upload your files to the server. If your files follow the naming convention <strong>{nid}_filename</strong> (where {nid} is the Node ID
of the target node), the created media will automatically associate with that node. <em>e.g.</em> <strong>35_myfile.tif</strong>
will create a media associated with node 35. If the files do not use this naming convention, the media will still be created,
<p>Upload your files to the server. If your files follow the naming convention <strong>{nid}_filename</strong> (where {nid} is the Node ID
of the target node), the created media will automatically associate with that node. <em>e.g.</em> <strong>35_myfile.tif</strong>
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.
</p>
<p> If you choose <strong><em>Already in place</em></strong>, unmanaged files in the destination folder will be now be managed
<p> If you choose <strong><em>Already in place</em></strong>, 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. </p>
<p>The source directory holds files to be ingested. The source directory must be identified by the full
<p>The source directory holds files to be ingested. The source directory must be identified by the full
server path <em>e.g.</em> <strong><em>/var/www/upload_folder</em></strong>.
</p>
<p>The destination directory will exist within the Drupal file system. The path is relative, and the folder will be created within the file system
<p>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.</p>
<p> 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. <em>n.b</em>. If your installation only uses one file system this choice is irrelevant
<p>
<p>File ownership is normally <strong>www-data:www-data</strong> on Apache systems and <strong>nginx:nginx</strong> for
a Docker based Islandora installation. The default value is normally fine, but confirm with your systems administrator
if you are unsure. <em>n.b</em>. If your installation only uses one file system this choice is irrelevant.
if you are unsure.
</p>";
return [
'#type' => 'markup',

12
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();

Loading…
Cancel
Save