Piotr Dorobisz edited this page Nov 1, 2015 · 10 revisions
Clone this wiki locally


This plugin provides controller that allows you to serve files from any directory on disk. You can specify multiple "root" directories which contain files that should be served. In request you have to specify root directory you want to get file from and path to file (relative to root).


Add plugin to grails-app/conf/BuildConfig.groovy:

grails.project.dependency.resolution = {
    plugins {
        runtime ':file-server:0.2.1'

Add download controller provided by this plugin to grails-app/conf/UrlMappings.groovy:

class UrlMappings {
    static mappings = {
        "/download/$root/$path**"(controller: "file")

Add all directories you want to serve files from to grails-app/conf/Config.groovy:

    "root1": "/path/to/dir1",
    "root2": "/path/to/dir2"

To enable logging for plugin's controller add following to grails-app/conf/Config.groovy:

log4j = {
    debug 'grails.app.controllers.org.grails.plugins.fileserver'


Specify in URL root directory you want to download file from and path to file (relative to root directory):
For example <APP_URL>/download/root1/dirA/dirB/somefile.txt refers to (according to configuration given in above example) /path/to/dir1/dirA/dirB/somefile.txt.
When file cannot be found or there is no root directory with name specified in URL controller will return error code 404.