<p>Why don't you just set up two separate asset sources, one default one with files being freely accessible and one source with access for logged-in users only by making use of that <a href="https://github.com/tikiatua/internal-assets-plugin" rel="nofollow">Internal Assets Plugin</a> you mentioned.</p>

<p>Instead of managing the rights with a lightswitch you would upload or move the assets in the right source.</p>

<p>Another option would be to have two asset fields for your entry type, one configured for each source. And you could then always hide one of them with a lightswitch using the brand new <a href="https://github.com/mmikkel/Reasons-Craft" rel="nofollow">Reasons</a> plugin.</p>

CC BY-SA 3.0
2015-05-26T18:56:11.320Z
Oh cool, new-to-me feature discovery: drag 'n' drop assets to different asset sources and Craft moves the file(s). Nice. This plus the plugin mentioned in the linked thread for private sources may do the trick, thanks!
Kirk Roberts
CC BY-SA 3.0
2015-05-26T14:29:32.267Z
2015-05-26T14:29:32.267Z
carlcs
<p>I found this post about restricting an entire asset source and placing it below the root level: <a href="https://craftcms.stackexchange.com/questions/804/is-it-possible-to-have-secure-private-assets">Is it possible to have secure (private) assets?</a></p>

<p>What I'd really like to do is be able to set the members-only restriction on a per-file basis, perhaps with a lightswitch field.</p>

<p>The imagined flow would be:</p>

<ul>
<li>user clicks a file link (anywhere, or even has a direct URL to the file)</li>
<li>.htaccess sends all .pdf, .doc, etc requests to a download checker page</li>
<li>download checker page sees if the requested file has the lightswitch checked</li>
<li>if no, download the file</li>
<li>if yes, 

<ul>
<li>if logged in, download the file</li>
<li>if not logged in, show the registration / login page

<ul>
<li>upon login or registration, start the file download</li>
</ul></li>
</ul></li>
</ul>

<p>I'm still relatively new to Craft and have the feeling there may be specific twig/craft abilities that make this — or something very similar — simple. I don't necessarily need the code handed to me, just some ideas about what tools are available to help with this process.</p>

<assets><member>
How can I restrict assets on a per-file basis?
# How can I restrict assets on a per-file basis?

(Asked by: username_0 on 2015-05-26)

I found this post about restricting an entire asset source and placing it below the root level: [Is it possible to have secure (private) assets?](https://craftcms.stackexchange.com/questions/804/is-it-possible-to-have-secure-private-assets)

What I'd really like to do is be able to set the members-only restriction on a per-file basis, perhaps with a lightswitch field.

The imagined flow would be:

* user clicks a file link (anywhere, or even has a direct URL to the file)
* .htaccess sends all .pdf, .doc, etc requests to a download checker page
* download checker page sees if the requested file has the lightswitch checked
* if no, download the file
* if yes,
  + if logged in, download the file
  + if not logged in, show the registration / login page
    - upon login or registration, start the file download

I'm still relatively new to Craft and have the feeling there may be specific twig/craft abilities that make this — or something very similar — simple. I don't necessarily need the code handed to me, just some ideas about what tools are available to help with this process.

**Tags:** assets, member


---

## 1 answers

### Answer by username_1 on 2015-05-26. Score: 3 | Accepted answer

Why don't you just set up two separate asset sources, one default one with files being freely accessible and one source with access for logged-in users only by making use of that [Internal Assets Plugin](https://github.com/tikiatua/internal-assets-plugin) you mentioned.

Instead of managing the rights with a lightswitch you would upload or move the assets in the right source.

Another option would be to have two asset fields for your entry type, one configured for each source. And you could then always hide one of them with a lightswitch using the brand new [Reasons](https://github.com/mmikkel/Reasons-Craft) plugin.

> **Comments:**
> **username_0**: Oh cool, new-to-me feature discovery: drag 'n' drop assets to different asset sources and Craft moves the file(s). Nice. This plus the plugin mentioned in the linked thread for private sources may do the trick, thanks!  

---

