Secure attachment url function

Resolves #117