Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Francis 19 posts 109 karma points
    May 16, 2024 @ 11:16
    Francis
    0

    V12.3.6 How to Obtain Media nodes from IPublishedMediaCache Using Context URL

    Hello,

    I wonder if you can help me out.

    I'm trying to implement a middleware that would intercept url requests from media files and find the media node for it for some processing.

    Example:

    If I enter https://localhost/mediafolder/4ghyxy/samplefile.pdf from the address bar, the middleware should intercept it and find the media node it's associated to and obtain it's properties for further processing

    This can easily be done in IMediaService by doing:

    var media = mediaService.GetMediaByPath(context.Request.Path);
    

    However, since this middleware would have multiple requests (I imagine) I wonder if I should be using the Media cache (IPublishedMediaCache) instead for this.

    My problem with that is I can't find any method of obtaining the node that is as efficient as the one above.

    enter image description here

    I would have to traverse through the media tree to obtain to find the file. Like so:

    enter image description here

    Question 1: Is there a more efficient way of doing in the IPublishedMediaCache?

    Question 2: Or is it ok to simply use the IMediaService in this middleware?

    Thanks in advance

Please Sign in or register to post replies

Write your reply to:

Draft