What service/helper/manager do I use to get the full file path of an media item (v10)?
# help-with-umbraco


02/11/2024, 11:00 PM
I am having trouble findding the relevant info in the docs. I have a media item (PDF file), I wish to attach this to an email. How can I find the full path of the media item? I am using v10. I have the file as a content model, so I can access the id etc. I used to use umbracoFile to do this, something akin to:
alas the property is no longert there, or I need to find it via one of the services/helpers. Thanks.


02/12/2024, 7:25 AM
Hi, I search for the similar issue and found the attached code as a replacement for Server.MapPath. I call the function as Website.Controllers.MapPathExtension.MapPath(Context, ldt.Url().ToString()). It works on Umbraco 13 site. I also wonder if this is the correct way to get the physical path for files. Thanks.


02/12/2024, 10:20 AM
@Matt Wise - not sure if I am being dense, but is there an example of how to get the actual path? The second example (contents as a stream) is passing in the path of the file, but I don't see where this is actually coming from.

Matt Wise

02/12/2024, 10:24 AM
Id have a look see what else is on the MEdiaFile Manager failing that you could use .Url() and swap the slashes 🙂


02/12/2024, 11:16 AM
Thanks, I'll check that out, but off the top off my head that's just going to give me a normal Url right? I'm not going to be able to use that to read create a stream attach to an email. I'll have a gander.


02/12/2024, 11:33 AM
Yes, you will be able to use a "normal" URL. In Umbraco file filesystem has been abstracted. The idea is that you shouldn't need to know the actual path (because it might not actually be a physical file on the local disk). As Matt points out, using the media file manager to interact with the media item directly is the proper way to do it - it already knows how to follow the URL you provide it to get at the actual file, wherever it is.


02/12/2024, 11:46 AM
thanks, I'll give this another go.