Unable to set a custom filename
jamieburchell opened this issue · 1 comments
It would be good if we could set a custom filename rather than relying on the filename of the file being served. In my case, the file to be served has a filename of random characters but I'd like to serve the file with a "friendly" name.
As it stands this can be done be implementing your own Resource
, the bundled FileResource
class does not enable you to do this but you could essentially copy/paste this and alter the getAdditionalHeaders()
method to emit a different file name in the Content-Disposition
header.
This library has been designed to be a "slim" framework and doesn't contain "extended" functionality like that, the possible variants of where data would be sourced (e.g. a database) and what meta-data might need to be included (e.g. Expires:
headers) are too wide to reasonably include everything all in one without making a very messy and confusing API. Rather than shipping the kitchen sink, I prefer the approach of good IoC design and interfaces - extensible rather than configurable in other words :-)