Protected image access

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
Andros
User
Posts: 113

Protected image access

Post by Andros »

I have a table with a "Photo" field where the user uploads an image. The image is uploaded to a public folder, and anyone with the link can view it. But now I need to make it available only to authenticated users. How can I do with ANM tools? Some idea?


MichaelG
User
Posts: 1139

Post by MichaelG »

Enable Tools -> Advanced Settings -> Encrypt file path.


Andros
User
Posts: 113

Post by Andros »

Ok thank you.
1)In practice what does this option?
2)Using ANM in VIEW page for UPLOAD TO FOLDER fields to view the image in the code there is an A HREF tag which points to "api/file/[token]", instead to point directly to the explicit folder and file name. Is there any ANM function to produce this piece of code in my custom pages also?


MichaelG
User
Posts: 1139

Post by MichaelG »

  1. The Encrypt file path option encrypt the image url so that the user cannot inspect the image url in the browser and directly access it. It can be enabled in Tools -> Advanced Settings -> Encrypt file path.
  2. For custom file, you need to encrypt and decrypt on your own (e.g. using the default Encrypt/Decrypt function).

Andros
User
Posts: 113

Post by Andros »

For the second point.
In my custom page I have a classic A tag to download my file
<a src="www.myapp.com/public/mydocs/mydoc123456.pdf">Download file</a>

How can I to use the encription?
Do I have to make the "public" folder not browsable?
Thanx


MichaelG
User
Posts: 1139

Post by MichaelG »

You need to create your own API action to server the file. Please read:
https://aspnetmaker.dev/docs/#/api.html ... api-action


Post Reply