Skip to content

Commit

Permalink
Implemented GetMediaByPath endpoint method
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Aug 27, 2024
1 parent ed77c82 commit e2f49cb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Limbo.Umbraco.MigrationsApi/MigrationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit e2f49cb

Please sign in to comment.