• Under the file/add menu item, files may be uploaded to the max upload size of the server.
  • With fields, each field may be configured to have its own max size.
  • In instances where the module is run on a shared server it may not be possible/may be impractical to alter the max upload limit.
  • It may be useful to allow file_entity to specify its own max upload size for files added through the file/add menu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

adammalone’s picture

attaching first prospective POC patch

adammalone’s picture

Status: Active » Needs review
aaron’s picture

Status: Needs review » Needs work

After testing, even though the message below the add file interface reads with the new limit, I am still able to upload larger files.

tobiasb’s picture

Status: Needs work » Needs review
FileSize
2.95 KB

* removed whitespace

The filesize validation is skipped for user 1. Therefore use a different user to test the patch.

aaron’s picture

Status: Needs review » Reviewed & tested by the community

This works for me.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs work

This should be altered into admin/config/media/file-system instead of adding a new page.

tobiasb’s picture

Status: Needs work » Needs review
FileSize
1.96 KB

Added the settings to file_entity_form_system_file_system_settings_alter().

aaron’s picture

Status: Needs review » Reviewed & tested by the community

This works as well.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs work
tobiasb’s picture

Status: Needs work » Needs review
FileSize
2.06 KB

Moved the settings to the new form.

aaron’s picture

Status: Needs review » Reviewed & tested by the community

Works as well.

Devin Carlson’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
3.21 KB

I've only found a few issues with #10; it looks good otherwise.

  1. +++ b/file_entity.admin.inc
    @@ -1070,6 +1070,15 @@ function file_entity_settings_form($form, &$form_state) {
    +    '#weight' => 5,
    

    Now that File entity has its own administration settings form setting a weight is unnecessary.

  2. +++ b/file_entity.pages.inc
    @@ -950,9 +950,13 @@ function file_entity_get_upload_validators(array $options = array()) {
    +  elseif (!empty($file_entity_max_filesize) && $file_entity_max_filesize < $max_filesize) {
    +    $validators['file_validate_size'] = array(parse_size($file_entity_max_filesize));
    +  }
    

    If the supplied $options['max_filesize'] pass the if{} statement then the elseif{} will never trigger, allowing other modules to bypass the user defined file size limit.

The new file_entity_max_filesize variable should also be added to the list of variables to delete during uninstall.

Devin Carlson’s picture

Devin Carlson’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.