I'm experimenting with the Play 2.0 framework on Scala. I'm trying to figure out how to send down custom HTTP headers–in this case, "Content-Disposition:attachment; filename=foo.bar". I can't seem to find documentation on how to do so (documentation on Play 2.0 is overall pretty sparse at this point).
Any hints?
Best Answer
The result types are in
play.api.mvc.Results
, see here on GitHub.In order to add headers, you'd write:
or
And here is a full sample download:
To download a file, Play now offers another simple way:
The disadvantage is that this results in an exception if the file is not found. Also, the filename is specified via a function, which seems a bit overkill.