sakaiproject/Hilary — pull request #245 by simong (2012-11-13 18:56:25+00:00)
Title: File Previews

This PR builds further on the [files PR](https://github.com/sakaiproject/Hilary/pull/228) (please merge that one first) and introduces file previews. The actual generation of file previews happens by a preview processor which is based off of Erik Froese's Java implementation from Nakamura. I've pushed that code into the [preview-processor repository](https://github.com/sakaiproject/preview-processor).

### Generating a preview
Whenever a new file gets uploaded a (node) event that holds the content ID id emitted. This gets piped via RabbitMQ to one of the Preview Processors. The PP downloads the file, processes it and uploads the preview images. The preview images are stored using the same techniques as regular files are stored.

### Listing a preview
In order to download the previews, the UI will need a list of available preview images. By doing a GET request to /api/content/:id/previews they retrieve that list *AND* an object with a signature and expires timestamp.

### Downloading a preview
With the previous obtained preview list and signature the UI is able to construct URLs to actually download the file. The signature is valid for 5 minutes and allows for doing fast permission checks on preview items as it would be unfeasible to check the access settings of the current user against each preview (as it is likely these will generate a lot of traffic.)
By using the signature there is only a need to do a single Cassandra query (retrieving the file uri).

### New REST endpoints:
* GET /api/content/:id/previews - Get a list of previews that are associated to this piece of content + a signature that is valid for 5 minutes.
* GET /api/content/:id/previews/page3.png?signature=:signature&expires=:expires - Download the preview item
* POST /api/content/:id/previews - Add new preview items (Admins only)