https://github.com/nfourtythree/secureassetdownload
Craft CMS plugin for secure asset download URLs
https://github.com/nfourtythree/secureassetdownload
assets craft-cms-plugin craft-plugin craftcms craftcms-plugin download
Last synced: about 1 month ago
JSON representation
Craft CMS plugin for secure asset download URLs
- Host: GitHub
- URL: https://github.com/nfourtythree/secureassetdownload
- Owner: nfourtythree
- Created: 2015-10-21T20:23:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-03T08:15:34.000Z (almost 8 years ago)
- Last Synced: 2025-03-25T14:12:12.336Z (about 2 months ago)
- Topics: assets, craft-cms-plugin, craft-plugin, craftcms, craftcms-plugin, download
- Language: PHP
- Size: 11.7 KB
- Stars: 21
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Secure Asset Download
Secure Asset Download is a simple Craft CMS plugin allowing you, from your templates, to generate download URLs for specified assets that are only available to certain users/groups
## Installing
1. Copy the `secureassetdownload` directory into your `craft/plugins` directory
2. Navigate to Settings > Plugins in the Craft CP
3. Click on the Install button next to Secure Asset Download
4. Set secret key in plugin settings by clicking Secure Asset Download
4. Use `{{ craft.secureAssetDownload.getUrl(options) }}` to generate secure URL (see usage below)## Settings
**Encryption Key:** Secret key used when encrypting the URLs
## Options
*asset* is the only required option. If no other options are set any logged in user will be able to access generated URLs.
Admins have access to all generated URLs regardless of options```
{
asset: id or AssetFileModel, // e.g 14 or craft.asset.id(23).first()
userId: id or array of user ids, // e.g. 6 or [ 17, 28, 30 ]
userGroupId: id or array of user group ids, // e.g. 3 or [ 1, 99, 76 ]
forceDownload: true or false, // Optional field to force the download rather than opening in the tab (default: true)
}
```_note_: Options are *AND* logic
## Usage
#### Secure for all logged in users ####
```
{% set options = {
asset: 17
} %}
```#### Secure for any user in specifc group ####
```
{% set options = {
asset: 17,
userGroupId: 2
} %}
```#### Secure for any user any specified group ####
```
{% set options = {
asset: 17,
userGroupId: [ 2, 6 ]
} %}
```#### Secure for specific users ####
```
{% set options = {
asset: 17,
userId: [ 46, 86 ]
} %}
```#### Secure for all users, don't force download ####
```
{% set options = {
asset: 17,
forceDownload: false
} %}
```**Followed by**
```
{% set url = craft.secureAssetDownload.getUrl(options) %}Download me
```## Changelog
[See Releases](https://github.com/nfourtythree/SecureAssetDownload/releases)