Overview

Drupal 7 brings us some big architectural achievements in the form of Entities. One of the most noticeable gains we get from entities is the establishment of the File Entity.

This is a very critical step towards much improved file handling capabilities. The File Entity creates an entry of each individual file in Drupal's database and gathers some important data about individual files. In turn, we're then able to do the following:

  • Relate files to the other entities that they're used on
    • Through the use of File Entity and the Media module, we can now actually see a report that shows us if a file is being used or not. This is really important, especially for sites that have a lot of files. If files aren't being used, they can be easily deleted, which can save a great deal of resources in terms of storage space.
  • Relate files to the users who uploaded them
    • This finally provides the opportunity to set ownership, and responsibility for the upkeep, of a file
  • Reuse files that have already been uploaded into the system
    • This was a very common issue in previous version of Drupal. People would upload the same file repeatedly because they had to use it in different locations. Now it's very easy to just do a simple search for a pre-existing file in the Media Library.
  • Create views of files
    • Since a File Entity has fields, it can now be made available to Views, where we can run advanced queries on files to better display and manage them.

This is all pretty exciting! Let's take a look at some of the different things we have to consider about files.