创建临时链接下载 [英] Create temporary link for download

查看:882
本文介绍了创建临时链接下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用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 tokens (which can be GUIDs) to expiration dates.

这篇关于创建临时链接下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆