Serve files that are not Stored in public accessible Directories. e.g for Password-Protected Areas. File links could and should not be shared!
The benefit of this is vs not having public Url's is you have a FilePreview in the CP even, the Files are not Public!
The file links are decoded to hide the path from the user and to make the link only accessible for the current Session, so that's the reason why it's not possible to share the links!
It's not meant to store sensitive data that possibly not should be leaked. But data that should not be found by SearchEngines or something like a ranking in a pdf file etc.
The links created by the plugin cannot be shared!
This plugin requires Craft CMS 4.0.0 or later.
if you want to help with this project, read how to contribute
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require itscoding/serve-secret
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for ServeSecret.
-
Crate a volume in craft that starts with
@secretStorage
. -
add
storage/secretStorage
to the gitignore dire if you use the @secretStorage alias. -
Use it in your templates --> put your asset as a method argument!
# the second parameter is optional, if is set to false, the file will download instead of open in the browser,the default value is true
<a href="{{ secretFile(entry.files.first(),false) }}">{{ entry.files.first().title }}</a>
{% for files in entry.files %}
<a href="{{ secretFile(file,true) }}">{{ file.title }}</a>
{% endfor %}
Some things to do, and ideas for potential features:
- Create sharable fileLinks
Brought to you by Simon Müller