improved file handling in Drupal 7

tagged with

While Drupal is, on aggregate, one of the best web platforms around, there's always room for improvement. Drupal 6 has one fairly important failing when it comes to files and file handling. During site configuration you are required to decide whether or not files are downloadable directly by the public or whether Drupal should maintain control of the downloads. This is/was a fairly inflexible system and one that led to further problems down the line...

One of the most serious problems that I ran into using Drupal 6 was a file aggregation issue. Because Drupal can end up including a large number of scripts and stylesheets in order to function, it is possible to aggregate files and combine them into one large file, which really helps provide a performance boost. However, file aggregation is not possible using the private file download method. This leaves you with a choice - you can either have file aggregation, or private downloads. If you require both (which is not unreasonable, bit not necessarily too common either) you are in trouble.

Enter Drupal 7. Not only is the file aggregation/private download method incompatibility resolved, but the entire way in which file downloads are controlled has changed. One of the big differences to Drupal 7 is the incorporation of a field based paradigm that pervades all content, comments, users and taxonomy. Instead of downloading the CCK contribution, fields are available anytime anywhere. By integrating file handling onto the file field, Drupal 7 allows for much finer grained control.

Now, as in Drupal 6, it is possible to specify a default file handling method (public or private). The difference however, is that for each file field, it is now possible to select the download method for the field in it's global context. Furthermore, you can specify how the file downloads are handled per field per content type.

So, for example, if you wanted to allow users to access files uploaded with the blog content type, but not for another premium content type, the public/private setting is made during the configuration of the added file field for that content type (Hint: to see this in action, click on 'manage fields' for the content type in D7, and add a File type field). The same field can store blog files to the public directory and premium files to the private directory (or any subdirectory as specified).

With this alone, Drupal 7 is going to be a great help to anyone and everyone who needs to work with file uploads and downloads via the Web.