I know this is an old question, but I happened here and thought of another alternative. You could return the mime type of the media file, so clients interested in that could just display it. The metadata could be added as a custom response header (with a JSON value if you prefer) so that metadata aware clients could extract the relevant information for the exact image returned without a race condition or double lookup.