From e2f49cb1f893294a8a0d5c805a9d3cbd5747a860 Mon Sep 17 00:00:00 2001 From: Anders Bjerner Date: Tue, 27 Aug 2024 14:36:47 +0200 Subject: [PATCH] Implemented GetMediaByPath endpoint method --- src/Limbo.Umbraco.MigrationsApi/MigrationsController.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Limbo.Umbraco.MigrationsApi/MigrationsController.cs b/src/Limbo.Umbraco.MigrationsApi/MigrationsController.cs index 534de3a..6136fce 100644 --- a/src/Limbo.Umbraco.MigrationsApi/MigrationsController.cs +++ b/src/Limbo.Umbraco.MigrationsApi/MigrationsController.cs @@ -12,6 +12,7 @@ using Skybrud.Essentials.Strings.Extensions; using Skybrud.Essentials.Time; using Skybrud.WebApi.Json; +using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Services; @@ -84,6 +85,14 @@ public object GetMediaByKey(Guid key) { return media == null ? NotFound() : MapMedia(media, MaxLevel); } + [HttpGet] + public object GetMediaByPath(string path) { + if (!HasAccess()) return Unauthorized(); + IMedia media = Current.Services.MediaService.GetMediaByPath(path); + IPublishedContent published = media == null ? null : Umbraco.Media(media.Key); + return media == null ? NotFound() : MapMedia(published, MaxLevel); + } + [HttpGet] public object GetMemberById(int id) { if (!HasAccess()) return Unauthorized();