Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, currencty I am download files from the server.

while it downloads its make link for downloads.(crome)

suppose I copy this link and give other this link he also able to download file

how can I prevent that?

What I have tried:

in crome after download link ..see in downloads.

copy this download link and give to others user .. on my computer it open that's not an issue.but I give to other users is able to download it again
I want to prevent that.
Posted
Updated 27-Feb-18 0:37am
Comments
F-ES Sitecore 27-Feb-18 6:33am    
You'd normally do something like generate a random string of text and store it in the Session as well as add it to the download link

/file/download?file=mypicture.jpg&code=randomtexthere

In the action that handles the download you read the code and make sure it matches the code in the Session. That way if someone else uses that link they won't have that code in their session so can't download the file.
Jaydeep Shah 27-Feb-18 8:40am    
Ok, i will try to add random text to a download link.
I am using Amazon S3.
download link expires after approx 3 minutes. (crome -> downloads )
but whiting 3 min anyone can download this file.

1 solution

That's not trivial - if you provide a download link to a file, then that link is direct to the file, and you can't easily prevent it.

Instead, have a "downloads page" which accepts a query string indicating the file - a GUID is a good idea, which a database linking the file location to the GUID value (with an expiry date is also a good idea). You then give them the download page and query string as the link.

In your page, you fetch the GUID value from the query, check the DB for the file, and send it as a download. You can then clean out the database to invlaidate the GUID for future downloads.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900