创建临时下载网址 [英] Creating temporary download URL

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

问题描述



我想创建允许用户下载数据的功能.流程如下

1.单击下载数据按钮
2.将文件名显示为超链接以下载数据.
3.用户单击文件名超链接,然后我们要在电子邮件中发送一个临时URL,供用户下载数据.

我们要下载的文件是zip文件,临时下载网址的主要原因是为了限制远程用户的未经授权的访问

我不知道如何创建一个临时URL,该URL有时会过期,不胜感激..谢谢

问候,
Praveen

Hi,

I want to create functionality to allow the user to download data..the flow is as follows

1.click download data button
2.show file names as hyperlinks to download data.
3.User clicks on file name hyperlink,then we want to send a temporary url in an email for the user to download data.

our files to download are zip files and the main reason for temporary download url is to restrict unauthorized access from remote users

I dont know how to create a temporary URL which expires after sometime, any help appreciated..thanks

regards,
Praveen

推荐答案

您可以看到此
单击
You can see this
Click


您好,

假设您知道如何编写文件下载部分的代码,我将告诉您所需要的解决方案的逻辑.

1.创建一个名为"DownloadTicketsTable"的表,该表具有字段"TicketNo",下载文件名",创建日期","TicketLiftTime"< b></b>
2.创建一个名为"dataList.aspx"的页面,在其中列出该用户可以下载的所有文件名.确保您没有提供指向确切文件的链接.
3.当用户单击某个文件时,将单击的文件名发布到另一个名为"downloads.aspx?filename = mytest.zip"的页面中,在其中为下载票证创建一个唯一ID(我建议Guid非常适合很好),并在"DownloadTicketsTable"中创建一条记录以及其他相关字段信息.
4.创建诸如"downloads.aspx?ticket = as4s1da23d23zwaw1"之类的链接,并将其提供给用户.
5.在"downloads.aspx"中检查票证ID,查询表,进行时间计算.
6.如果票证尚未过期,请将文件数据写回用户.如果已过期,请向用户返回错误消息对不起.此下载票证已过期"

注意:文件名,页面名,GET数据仅用于说明目的.请随意更改名称和逻辑.

希望这会有所帮助.

谢谢Pasan.
Hi there

Assuming you know how to code the file download part, I''ll tell you the logic of the solution that you are looking for.

1. Create a table named "DownloadTicketsTable" which has fields "TicketNo", "Download File Name", "Date Created", "TicketLiftTime"<b></b>
2. Make a page called "dataList.aspx" in which, you list all the file names that are available for that user to download. Make sure, you don''t provide the link to the exact file.
3. When the user clicks on a certain file, post the clicked file name to another page named "downloads.aspx?filename=mytest.zip" in which you create a unique ID for the download ticket (I suggest a Guid would fit very well) and make create a record in the "DownloadTicketsTable" with the other relevant field information.
4. Create links like "downloads.aspx?ticket=as4s1da23d23zwaw1" and give it to the user.
5. In the "downloads.aspx" check for the ticket id, query your table, do the time calculations.
6. If the ticket has not expired, write the file data back to the user. If it has expired, return an error message to the user "Sorry. This download ticket has expired"

Note: The names of the files, page names, GET data are just used for explaining purposes. Please, feel free to change the names, logic as fit.

Hope this helps.

Regards, Pasan.


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

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