Answers.Body: <p>Give <a href="https://craftpl.us/plugins/digital-download" rel="nofollow noreferrer">Digital Download</a> a try... it generates a masked URL for downloadable assets. You can restrict the download to a specific user or user group. </p>
  
  <p><em>Disclaimer: I'm the plugin author.</em></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-04T00:33:12.403Z
Answers.Text: Does it prevent direct access to the files?
Answers.UserDisplayName: ponies
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-04T02:42:45.193Z
Answers.Text: Yes, you can use the plugin with non-public files.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-30T14:03:04.227Z
Answers.LastActivityDate: 2017-03-30T14:03:04.227Z
Answers.UserDisplayName: Lindsey D
Answers.Body: <p>Make sure that your /craft/config/general.php has the right reference to the plugin. If you have 'internalAssetsUrl' => "<a href="http://website.loc/media/" rel="nofollow noreferrer">http://website.loc/media/</a>", then you need to change the InternalAssetsPlugin.php-file from </p>
  
  <pre><code>return array(
  'internal/(?P&lt;id&gt;.\d*)' =&gt; array('action' =&gt; 
  'InternalAssets/Assets/download'),
  'internal/(?P&lt;directory&gt;.*)/(?P&lt;name&gt;.*)' =&gt; array('action' =&gt; 
  'InternalAssets/Assets/view')
  );
  </code></pre>
  
  <p>to</p>
  
  <pre><code>return array(
  'media/(?P&lt;id&gt;.\d*)' =&gt; array('action' =&gt; 'InternalAssets/Assets/download'),
  'media/(?P&lt;directory&gt;.*)/(?P&lt;name&gt;.*)' =&gt; array('action' =&gt; 
  'InternalAssets/Assets/view')
  );
  </code></pre>
  
  <p>in other words, just change 'internal' to 'media'.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-13T07:42:17.753Z
Answers.LastActivityDate: 2017-07-13T07:42:17.753Z
Answers.UserDisplayName: Jay
Body: <p>I'm creating a website where I want users to be able to login. I'm using <a href="https://craftcms.com/docs/templating/login-form" rel="nofollow noreferrer">https://craftcms.com/docs/templating/login-form</a> to achieve this. No problem so far.</p>
  
  <p>When a user is logged in, I want the user to be able to reach the asset folder (depending on what the rights are for his user-group). When not logged in, I want the asset url to be private.
  For this to work I've placed the asset folder outside the webroot, so you can't access the asset folder by default.</p>
  
  <p>I've tried to achieve this with this plugin: <a href="https://github.com/tikiatua/internal-assets-plugin" rel="nofollow noreferrer">https://github.com/tikiatua/internal-assets-plugin</a>
  But without any success.</p>
  
  <p>My general config:</p>
  
  <pre><code>'enableTemplateCaching' =&gt; false,
      'devMode' =&gt; true,
      'siteUrl' =&gt; 'http://website.loc/',
      'loginPath' =&gt; 'http://website.loc/',
      'environmentVariables' =&gt; array(
          'internalAssetsPath' =&gt; CRAFT_BASE_PATH . "../media/",
          'internalAssetsUrl' =&gt; "http://website.loc/media/"
      )
  </code></pre>
  
  <p>I can upload a image in my internalAssetsPath, but when I try to show this in front-end, I get a 404.</p>
  
  <pre><code>{% for image in craft.assets.kind('image') %}
          &lt;li&gt;&lt;img src="{{ image.getUrl() }}" alt="{{ image.title }}"&gt;&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>A solution for the 404 problem would be nice, but a solution for reaching the asset folder when logged in would be great.</p>
  
Tags: <assets><login><user-groups>
Title: Public url for assets when logged-in
ThreadText: # Public url for assets when logged-in
  
  (Asked by: username_0 on 2017-03-30)
  
  I'm creating a website where I want users to be able to login. I'm using <https://craftcms.com/docs/templating/login-form> to achieve this. No problem so far.
  
  When a user is logged in, I want the user to be able to reach the asset folder (depending on what the rights are for his user-group). When not logged in, I want the asset url to be private.
  For this to work I've placed the asset folder outside the webroot, so you can't access the asset folder by default.
  
  I've tried to achieve this with this plugin: <https://github.com/tikiatua/internal-assets-plugin>
  But without any success.
  
  My general config:
  
  ```
  'enableTemplateCaching' => false,
      'devMode' => true,
      'siteUrl' => 'http://website.loc/',
      'loginPath' => 'http://website.loc/',
      'environmentVariables' => array(
          'internalAssetsPath' => CRAFT_BASE_PATH . "../media/",
          'internalAssetsUrl' => "http://website.loc/media/"
      )
  
  ```
  
  I can upload a image in my internalAssetsPath, but when I try to show this in front-end, I get a 404.
  
  ```
  {% for image in craft.assets.kind('image') %}
          <li><img src="{{ image.getUrl() }}" alt="{{ image.title }}"></li>
  {% endfor %}
  
  ```
  
  A solution for the 404 problem would be nice, but a solution for reaching the asset folder when logged in would be great.
  
  **Tags:** assets, login, user-groups
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2017-03-30. Score: 2
  
  Give [Digital Download](https://craftpl.us/plugins/digital-download) a try... it generates a masked URL for downloadable assets. You can restrict the download to a specific user or user group.
  
  *Disclaimer: I'm the plugin author.*
  
  > **Comments:**
  > **username_2**: Does it prevent direct access to the files?  
  > **username_1**: Yes, you can use the plugin with non-public files.  
  
  ---
  
  ### Answer by username_3 on 2017-07-13. Score: 1
  
  Make sure that your /craft/config/general.php has the right reference to the plugin. If you have 'internalAssetsUrl' => "<http://website.loc/media/>", then you need to change the InternalAssetsPlugin.php-file from
  
  ```
  return array(
  'internal/(?P<id>.\d*)' => array('action' => 
  'InternalAssets/Assets/download'),
  'internal/(?P<directory>.*)/(?P<name>.*)' => array('action' => 
  'InternalAssets/Assets/view')
  );
  
  ```
  
  to
  
  ```
  return array(
  'media/(?P<id>.\d*)' => array('action' => 'InternalAssets/Assets/download'),
  'media/(?P<directory>.*)/(?P<name>.*)' => array('action' => 
  'InternalAssets/Assets/view')
  );
  
  ```
  
  in other words, just change 'internal' to 'media'.
  
  
  ---
  
  