问题描述
我用ASP.NET结果
我需要给用户临时链接,从服务器下载文件。结果
它应该是一个临时链接(页),这是可以在短时间内(12小时例如)。我该如何生成这个链接(或临时网页连结的人)?
http://example.com/download/document.pdf?token=<token>
的&LT;令牌GT;
部分在这里是关键。如果你不想涉及数据库,加密链接创建的时间,将其转换为安全网址Base64再presentation,给用户的URL。当它的要求,解密标记
和比较储存在那里与当前日期和时间日期。
另外,你可以有一个单独的 DownloadTokens
表至极将地图说标记
S(可以是的GUID)到截止日期。
I use ASP.NET
I need to give user temporary link for downloading file from server.
It should be a temporary link (page), which is available for a short time (12 hours for example). How can I generate this link (or temporary web page with link)?
http://example.com/download/document.pdf?token=<token>
The <token>
part is key here. If you don't want to involve a database, encrypt link creation time, convert it to URL-safe Base64 representation and give user that URL. When it's requested, decrypt token
and compare date stored in there with current date and time.
Alternatively, you can have a separate DownloadTokens
table wich will map said token
s (which can be GUIDs) to expiration dates.
这篇关于创建临时链接下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!