This project is not covered by Drupal’s security advisory policy.

Local / Network Files provides two field types that are geared to an intranet / internal web application site. Both field types accept text input, and generate output as follows:

  1. Local / Network Files: the full path to a file on the local file system / network. That path is then rendered as either a link or plain text.
  2. Local / Network Paths: the full path to a folder on the local file system / network. That folder and its contents is then rendered as a tree, with files in the folder and subfolders as either links or plain text.

Who Would Use this Module?

The use-case that was the originator for this module was tying case-related file system folders into a case management web application. Using content-types for stakeholders, cases, activities, tasks, and documents, a pretty decent case-management system can be created with Drupal, leveraging Views, Panels, and Display Suite to show all activities, tasks, and documents having to do with a case, and linking everything for relatively smooth navigation. However, one thing that was missing was the ability to see plain-old-file-system files in that case view. And those files existed completely outside the web root. Drupal's built-in file facilities won't do it, and I couldn't find a contrib module that really worked properly either in terms of providing a simple window into some directory out on the corporate network from that case web page. The one that came closest to what I wanted was FileTree, but it's an input filter, not a field, and again only showed file trees within the site's file systems, not outside. Nonetheless, a big chunk of code for this module was inspired by / borrowed from FileTree.

File Link Protocols

The module uses two protocols for rendering links. One is a simple "FILE://<drive_letter>:/<path>" protocol, which is ignored by most browsers (they won't attempt to open the link) for security reasons. There are some browser add-ons out there that facilitate using these links (such as LocalLink for FireFox), but the user still has to pass normal network permissions to get to the file. The other protocol is HTTP through the webserver, where the file is delivered to the browser via HTTP. The use of this protocol has the advantage that in browsers like FireFox, the user is prompted if they want to open the file in the associated application, and so is a bit of a nicer user experience, although normal network permissions could be bypassed.

Permissions and Security

Because this module exposes the local network file system(s) to end users, special precautions should be taken, as it is the account under which the webserver is running that in fact accesses the files, not the user's network account, in the case of the file link protocol being HTTP. There are three permissions with this module: access files using HTTP, create the file-type field, and create the path-type field. This allows system administrators to not only restrict which roles are permitted to access / download files to their browser via HTTP potentially bypassing normal network permissions, but also which of the roles that have "Administer Content Types" (i.e., create and modify content types) can actually use these kind of fields when creating or modifying content types.

In addition, there are settings on the field settings form that further restrict paths that users can enter into content of the content-type using one of these fields. For example, when setting up the field, paths can (and should) be restricted to having to start with a certain path. This in conjunction with the download function itself not allowing any "/../" constructs in the path ensures that only files below a certain folder can be accessed.

Installation and Configuration

Install the module as you would any other Drupal module. Each instance of the field is configured via the "Manage Fields" tab for the entity, and for its various display options under the "Manage display" tab.

There are settings on the field settings form that specify the protocol to be used (see above), restrict paths that users can enter into content of the content-type using one of these fields, and for mapping logical drives to different logical drives and an optional path, accommodating the scenario where a user's local drive maps to a share on the server that is in fact on a different drive letter and a subfolder on that drive.

Display configuration for files includes how to list the files (ordered list, unordered list, or simple divs) and whether or not to render the paths as links. For paths, there are options on how to show the file and folder names, as well, as hover titles, and again whether or not to render the files names as links.

Dependencies

Field for obvious reasons.
Token for pattern-substitution in the rendering of folder trees.

Project information

Releases