<p>I guess that each of these PDFs are related to an entry using an assets field.</p>

<p>If this is true, you could add an extra field "Random Path" to that entry and use that field's value as a segment of your PDF's URL.</p>

<p>You can achieve this by setting the upload location for the PDFs to a subfolder named after that field's value. You set the subfolder path (i.e. to <code>{randomPath}</code>) in Settings → Fields → "myAssetField" → Default Upload Location.</p>

<p>If the <code>randomPath</code> field has a value of <code>mUampRNYxcwXampC9QX</code>, an PDF file <code>mySecureFile.pdf</code> is saved like so: <code>/myPdfFolder/mUampRNYxcwXampC9QX/mySecureFile.pdf</code> (in fact it is moved after the entry is saved).</p>

<p>To generate random strings for that field, use the fantastic Craft plugin <a href="https://github.com/sjelfull/Craft-Randomm" rel="nofollow">"Randomm"</a> by Fred Calsen.</p>

CC BY-SA 3.0
2014-10-28T13:33:46.910Z
Yes they are related to entries in a channel. However, there are 3 per entry but I guess that doesn't really matter. Will look at the Randomm thing, thanks.
hamishtaplin
CC BY-SA 3.0
2014-10-28T14:06:08.397Z
@hamishtaplin it'd be nice if one could assign the `randomPath` field as a meta field to your PDF asset source. And then use the field value of each asset individually to define the subfolder path. This: `{myAssetfield.randomPath}` can't work, but maybe there's a way to do this?!
carlcs
CC BY-SA 3.0
2014-10-28T12:52:13.167Z
2014-10-28T12:52:13.167Z
carlcs
<p>You can use the <a href="https://github.com/tikiatua/internal-assets-plugin" rel="nofollow">Internal Assets Plugin</a> to have assets above your web root.</p>

CC BY-SA 3.0
2014-10-30T11:08:10.243Z
That's interesting, might be helpful.
hamishtaplin
CC BY-SA 3.0
2014-10-29T19:07:44.693Z
2014-10-29T19:07:44.693Z
Lars Bilke
<p>I'm building a site with digital downloads of PDFs via the excellent <a href="http://squarebit.co.uk/plugins/charge/" rel="nofollow">Charge</a> plugin and need to include some basic obfuscation of the path to files to prevent people from just being able to predict them. I was thinking maybe I can use the UID of the assets to identify it, is this possible? If not any suggestions are welcome.</p>

<assets>
Obfuscation of an asset's file path?
# Obfuscation of an asset's file path?

(Asked by: username_0 on 2014-10-28)

I'm building a site with digital downloads of PDFs via the excellent [Charge](http://squarebit.co.uk/plugins/charge/) plugin and need to include some basic obfuscation of the path to files to prevent people from just being able to predict them. I was thinking maybe I can use the UID of the assets to identify it, is this possible? If not any suggestions are welcome.

**Tags:** assets


---

## 2 answers

### Answer by username_1 on 2014-10-28. Score: 2

I guess that each of these PDFs are related to an entry using an assets field.

If this is true, you could add an extra field "Random Path" to that entry and use that field's value as a segment of your PDF's URL.

You can achieve this by setting the upload location for the PDFs to a subfolder named after that field's value. You set the subfolder path (i.e. to `{randomPath}`) in Settings → Fields → "myAssetField" → Default Upload Location.

If the `randomPath` field has a value of `mUampRNYxcwXampC9QX`, an PDF file `mySecureFile.pdf` is saved like so: `/myPdfFolder/mUampRNYxcwXampC9QX/mySecureFile.pdf` (in fact it is moved after the entry is saved).

To generate random strings for that field, use the fantastic Craft plugin ["Randomm"](https://github.com/sjelfull/Craft-Randomm) by Fred Calsen.

> **Comments:**
> **username_0**: Yes they are related to entries in a channel. However, there are 3 per entry but I guess that doesn't really matter. Will look at the Randomm thing, thanks.  
> **username_1**: @username_0 it'd be nice if one could assign the `randomPath` field as a meta field to your PDF asset source. And then use the field value of each asset individually to define the subfolder path. This: `{myAssetfield.randomPath}` can't work, but maybe there's a way to do this?!  

---

### Answer by username_2 on 2014-10-29. Score: 0

You can use the [Internal Assets Plugin](https://github.com/tikiatua/internal-assets-plugin) to have assets above your web root.

> **Comments:**
> **username_0**: That's interesting, might be helpful.  

---

