Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow modules to add/modify allowed File extensions #1137

Open
mjordan opened this issue Jun 2, 2019 · 7 comments
Open

Allow modules to add/modify allowed File extensions #1137

mjordan opened this issue Jun 2, 2019 · 7 comments
Labels
Type: enhancement Identifies work on an enhancement to the Islandora codebase

Comments

@mjordan
Copy link
Contributor

mjordan commented Jun 2, 2019

Currently, the list of extensions allowed for "File" Media are hard coded in islandora/modules/islandora_core_feature/config/install/field.field.media.file.field_media_file.yml. They are:

file_extensions: 'txt rtf doc docx ppt pptx xls xlsx pdf odf odg odp ods odt fodt fods fodp fodg key numbers pages tiff tif jp2'

Modules should be able to alter this list, to allow for uploading of files whose extensions are not present (or removing extensions from the list to disallow uploading of specific types).

@Natkeeran
Copy link
Contributor

@mjordan
Copy link
Contributor Author

mjordan commented Jun 2, 2019

Super! Thanks!

@mjordan mjordan closed this as completed Jun 2, 2019
@mjordan
Copy link
Contributor Author

mjordan commented Jun 2, 2019

Reopening this since it probably should be added to https://github.com/Islandora-CLAW/CLAW/blob/master/docs/user-documentation/datastreams.md.

@mjordan mjordan reopened this Jun 2, 2019
@mjordan
Copy link
Contributor Author

mjordan commented Jun 2, 2019

I am also thinking that we should document for developers how to override this list either in configuration or in code. For example, if I add some functionality in a custom module that allows uploading of .xml files, I should not need to tell admins "Step 5: Visit admin/structure/media/manage/file/fields/media.file.field_media_file and add 'xml' to the list of allowed extensions."

@seth-shaw-unlv
Copy link
Contributor

seth-shaw-unlv commented Jun 5, 2019

@mjordan You can modify it inside a module's hook_install. I can provide an example later. @ajstanley beat me to it.

@Natkeeran
Copy link
Contributor

For those who want to not to do any configuration outside of ansible, one approach might be to update the field.field.media.file.field_media_file.yml, then put into a post install task.

@ajstanley
Copy link
Contributor

ajstanley commented Jun 5, 2019

I stick this in hook_install
// Add myext extension if it doesn't already exist;
$field = FieldConfig::load("media.file.field_media_file");
$fieldSettings = $field->getSettings();
$extensions = $fieldSettings['file_extensions'];
if (!strpos($extensions, 'myext')) {
$fieldSettings['file_extensions'] .= ' myext';
$field->set('settings', $fieldSettings);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: enhancement Identifies work on an enhancement to the Islandora codebase
Projects
Development

No branches or pull requests

5 participants