This allows you to protect media and folders by the same membership groups that are built into Umbraco's Members system, so if yo have a Member Group for 'Logged in' you can protect a particular PDF files to be only downloaded by people in that group.
It is a paid for package, and in order for it to work, it does have to look at all requests coming in the pattern of /media/* and looking to see if it's protected by member groups, so there is a little overhead (but usually that's not a deal breaker!)
If you want to write code to handle this yourself, then you could create your own IhttpModule and look for the requests yourself - which might be preferable if you only want to protect this one PDF, etc and don't want to introduce the package.
or you can roll your own IHttpModule to suit your needs, in the example one I linked to we, just went with a convention, eg Umbraco allows to create different MediaTypes other than the default so we created a ProtectedFolder MediaType, and then any requests from images that were in that folder needed to be logged in... but there are a number of ways of doing it.
pdf for logged in users only
The PDF that I uploaded should only be available for logged-in users. However, I don't know how to implement this. Does somebody has any idea?
Hi Jessica
The quick answer is there is a third party plugin that would do this called Media Protect
https://our.umbraco.com/packages/website-utilities/media-protect/
This allows you to protect media and folders by the same membership groups that are built into Umbraco's Members system, so if yo have a Member Group for 'Logged in' you can protect a particular PDF files to be only downloaded by people in that group.
It is a paid for package, and in order for it to work, it does have to look at all requests coming in the pattern of /media/* and looking to see if it's protected by member groups, so there is a little overhead (but usually that's not a deal breaker!)
If you want to write code to handle this yourself, then you could create your own IhttpModule and look for the requests yourself - which might be preferable if you only want to protect this one PDF, etc and don't want to introduce the package.
There is an example here of something similar at the old place I worked: https://github.com/Moriyama-Umbraco/Moriyama-Authorised-Media/blob/master/src/Moriyama.AuthorisedMedia/Application/AuthorisedMediaHttpModule.cs Where we had the concept of protecting anything that was 'in' a special Media Folder Type, that could be a source of inspiration.
regards
Marc
Hello Marc,
it's about several pdf.
regards
Jessica
Hi Jessica
More information about Media Protect here: https://soetemansoftware.nl/media-protect
or you can roll your own IHttpModule to suit your needs, in the example one I linked to we, just went with a convention, eg Umbraco allows to create different MediaTypes other than the default so we created a ProtectedFolder MediaType, and then any requests from images that were in that folder needed to be logged in... but there are a number of ways of doing it.
or MediaProtect might be just what you need.
regards
marc
is working on a reply...