There's no guaranteed way of finding the right Content-Type for a file. We infer the type by the file extension, or we can try and detect a magic number in the file, or we can look for specific set of bytes that usually indicates the type. There are a number of different ways, and none of them are foolproof.
This means that I'd prefer this functionality to be separate from the file-response and resource-response functions, either as additional middleware or as a function that wraps file-response and resource-response.
- James