function hook_file_presave

Act on a file being inserted or updated.

This hook is called when a file has been added to the database. The hook doesn't distinguish between files created as a result of a copy or those created by an upload.

Parameters

Drupal\file\File $file: The file entity that is about to be created or updated.

1 function implements hook_file_presave()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

entity_crud_hook_test_file_presave in drupal/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module
Implements hook_file_presave().

File

drupal/core/modules/file/file.api.php, line 83
Hooks for file module.

Code

function hook_file_presave(Drupal\file\File $file) {

  // Change the file timestamp to an hour prior.
  $file->timestamp -= 3600;
}