Get Media File by Name in Umbraco 13

Hi there,
I’ve been searching documentation and the web, while trying quite a few ways to simply lookup a media file by a name (“file.pdf”), by using the Umbraco API for the Media Service and/or Media File Manager, and I can’t seem to accomplish it by using file name (versus path, GUID, etc).

I am refactoring older code that used SQL to directly check for the file name in the database, but I want to have it updated.

Is there no other way to check for existing media file?

I actually had a pretty elaborate set of methods that would look locally, and then if no, would switch to look in the blob service. But this seemed like stepping outside the context of Umbraco’s capabilities.


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/114241-get-media-file-by-name-in-umbraco-13