Eli Blokh
Eli Blokh

Reputation: 12293

Give link to download file from server

I use ASP.NET.

I have several audio files on the server and I should give user a temporary link for downloading. It meens that after several hours link should be unavailable For example I give user: www.mysite.com/files/111.mp3, but how to protect www.mysite.com/files/ from direct access and downloading by any user?Is the UrlRewriting what I need?

How can I make a temporary web-page/link for downloading and protecting files from direct access from adress line?

Maybe I should store files in database(I have SQL Server 2008)?Can it help?

Upvotes: 1

Views: 1474

Answers (1)

Mohammed Swillam
Mohammed Swillam

Reputation: 9242

I think you will need a way to manage the temp links (say a DB with time stamps) and when you get a request by one of these links, you gonna use HttpHandlers to intercept this request, fetch your database by the requested link.

if the given period of time still current, you will get the actual file from the server and let the Httphandler send it back to the user as a stream.

this way, the end user will still get the requested file, but he will see that he is getting the file from your temp link (say: http://mysite.com/files/kdhsdg52354d) and will not be able to reuse it again after the your defined period.

sorry, I'm in a rush so couldn't format the answer better :).

Upvotes: 1

Related Questions