What service/helper/manager do I use to get the fu...
# help-with-umbraco
z
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:
Server.MapPath(trainingLogFile.GetPropertyValue("umbracoFile").ToString());
alas the property is no longert there, or I need to find it via one of the services/helpers. Thanks.
o
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. https://cdn.discordapp.com/attachments/1206374268347088907/1206501192704725022/MapPath.cs?ex=65dc3ccc&is=65c9c7cc&hm=6f9573892b7d7dec2275bd1d1bbe05b619f16578734c9b40b604fa26a2b4a280&
z
@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.
m
Id have a look see what else is on the MEdiaFile Manager failing that you could use .Url() and swap the slashes 🙂
z
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.
j
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.
z
thanks, I'll give this another go.
31 Views