Scenario
An agency requires that a certain file be published at a precise point in time. The file is time sensitive and prior receipt of the information by the public is not desirable. Typical examples include the release of a PDF or CSV. This scenario differs from the one above as we are dealing with files, which typically exist in the files directory, open to the public. The usual publishing workflows and content access rules do not apply to such files. A public file is visible to anyone if they know the URL.
Challenge
The core challenge is that public files are available to anyone if they know the URL. It is not easy to switch the access on a file if it is public and this poses a massive problem for agencies wishing to publish time sensitive files.
Solution
There are three possible solutions, none of which are perfect.
- Private files: Access to private files is controlled by Drupal. When a private file is attached to a node it inherits the permissions on that node. If the node is unpublished, so is the file. This is a good solution where a heavy load is not expected. A PHP process will need to be invoked for each file request and this will place load on the server. This solution will work on intranets, but not on a site on the open web.
- Upload when needed: The most pragmatic solution is just to upload the file as a public file when needed. This process is manual but it does have the advantage of keeping things simple.
- Custom code when node is published: It is possible to hook into the submit handler on the node save form to move the embargoed file from the private file system to the public system. This is the most “hacky” approach but it does solve the problem of making the file public. This approach has been used to great effect for the bulk publishing of Media assets. Unfortunately, this approach will not work for scheduled transitions as there is no form submit handler to hook into.
Outcome
This is a difficult area. The best approach may be to use Scheduled Transitions for the node content, and then to upload the attached data file after the content is public. The difficulties here are related more to Drupal and CDNs than they are to GovCMS. The best approach is to review the needs of the site and then select from the available options.