//mediaId is the ID returned from your document property...
Media file = new Media(mediaId);
string url = file.getProperty("umbracoFile").Value.ToString();
OR
var mediaFile = ApplicationContext.Current.Services.MediaService.GetById(1198);
var url = mediaFile.GetValue("umbracoFile").ToString();
Get media URL on server
Hi I have a REST service (I am using AngularJS) which have e view model, so this model have a Image property, which I would like to add.
But how do I find the Image Url from the media id?
I have tried to fizzle around with library.GetMedia(mediaId, false). But this keeps sending me a weird url with some adtional numbers?
Is there an easy way to get a media url from a media's id from a REST controller?
So please answer without Razor or XSLT examples :)
Have a look at this post:
https://our.umbraco.org/forum/developers/api-questions/7993-Get-URL-of-media-file
Bottom line:
OR
Hope that helps
JT
Thank you so much! It was exactly was I was looking for!
I working in Helper class to my service layer, so getting the context solved some more issues :)
is working on a reply...