Copied to clipboard

Flag this post as spam?

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


  • wilmar 19 posts 129 karma points
    Feb 05, 2021 @ 10:58
    wilmar
    0

    Any way to protect media folder using custom pipelines ?

    I need to apply custom logic to the items inside the media library. for example protecting certain files , apply custom weird logic. my point is i want to write custom code to manage the reading of files via pipelines. i tried to build my own mediaurl provider but this will only be called when you use .Url()

      public class MyUrlProvider : IMediaUrlProvider
        {
            public UrlInfo GetMediaUrl(UmbracoContext umbracoContext, Umbraco.Core.Models.PublishedContent.IPublishedContent content, string propertyAlias, Umbraco.Core.Models.PublishedContent.UrlMode mode, string culture, Uri current)
            {
                //something happens here en you call .Url()
    
                return null;
            }
        }
    

    Then i tried to override the media URL in different ways

    // this should override all posible url slugs !! 
    //and it does but does not work with /media 
         RouteTable.Routes.MapRoute("MediaRoute", "{*permalink}", new
                    {
                        controller = "Media",
    
                        action = "IndexMedia",
                    }, 
    
                      constraints: new { name = new MediaContraint() }
                    );
    
    
    
     //this works with media/someId/myimge.png
                    RouteTable.Routes.MapUmbracoRoute("MediaRoute", "media/{id}/{file}", new
                    {
                        controller = "Media",
                        id = UrlParameter.Optional,
                        file = UrlParameter.Optional,
                        action = "Index",
                    }, new test(),
                    constraints: new { name = new MediaContraint() });
    

    but does not work with this url /media/someID/mypicture.jpg?Width="300" i found this articule but this not work with umbraco 8 https://farmcode.org/articles/securing-the-media-section-in-umbraco-behind-a-login/

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Feb 05, 2021 @ 17:19
    Dan Diplo
    0

    Would this article be of help?

    https://codeshare.co.uk/blog/how-to-protect-media-items-in-umbraco/

    There are also commercial packages that can protect media, to save you the trouble!

    https://soetemansoftware.nl/media-protect

  • McLaughlin418 1 post 71 karma points
    Feb 09, 2021 @ 07:38
    McLaughlin418
    0

    I need to apply custom logic to the items inside the media library. for example protecting certain files , apply custom weird logic. kroger hr expressmy point is i want to write custom code to manage the reading of files via pipelines. i tried to build my own mediaurl provider but this will only be called when you use .Url()

    public class MyUrlProvider : IMediaUrlProvider { public UrlInfo GetMediaUrl(UmbracoContext umbracoContext, Umbraco.Core.Models.PublishedContent.IPublishedContent content, string propertyAlias, Umbraco.Core.Models.PublishedContent.UrlMode mode, string culture, Uri current) { //something happens here en you call .Url()

            return null;
        }
    } Then i tried to override the media URL in different ways
    

    // this should override all posible url slugs !! //and it does but does not work with /media RouteTable.Routes.MapRoute("MediaRoute", "{*permalink}", new { controller = "Media",

                    action = "IndexMedia",
                }, 
    
                  constraints: new { name = new MediaContraint() }
                );
    

    //this works with media/someId/myimge.png RouteTable.Routes.MapUmbracoRoute("MediaRoute", "media/{id}/{file}", new { controller = "Media", id = UrlParameter.Optional, file = UrlParameter.Optional, action = "Index", }, new test(), constraints: new { name = new MediaContraint() }); but does not work with this url /media/someID/mypicture.jpg?Width="300" i found this articule but this not work with umbraco 8 https://farmcode.org/articles/securing-the-media-section-in-umbraco-behind-a-login/

    The pipelines keep an internal queue of those media URLs which are currently If some file failed downloading, an error will be logged and the file won't be present in full is a sub-directory to separate full images from thumbnails (if used). You can override this method to customize the download path of each file.

Please Sign in or register to post replies

Write your reply to:

Draft