与传统的ASP大文件的工作 [英] Working with big files in classic ASP

查看:133
本文介绍了与传统的ASP大文件的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道什么是对传统的ASP服务生成的大文件中的最佳实践。

I was wondering what's the best practise for serving a generated big file in classic asp.

我们有一个应用程序导出到Excel产生10MB文件的功能。该过人之处由只调用具有Response.ContentType组脱颖而出,并先后为数据的HTML表.asp页创建。

We have an application with "export to excel" function that produces 10MB files. The excels are created by just calling a .asp page that has the Response.ContentType set to excel and has an HTML table for the data.

这给了作为它需要4分钟,用户看到的另存为...对话框之前的问题。

This gives as problem that it takes 4 minutes before the user sees the "Save as..." dialog.

我目前的解决方法是调用与AJAX在服务器上创建的Excel和让页返回生成文档的URL的.asp页。然后,我可以使用JavaScript来显示原来的页面上。

My current solution is to call an .asp page that creates the excel on the server with AJAX and lets the page return the URL of the generated document. Then I can use javascript to display the on the original page.

这是很容易做到与传统的ASP(具有某种流的创建对服务器上文件),同时保持安全考虑的? (URL应该使人们可以猜到的其他文件的位置)

Is this easy to do with classic asp (creating files on server with some kind of stream) while keeping security in mind? (URL should make people be able to guess the location of other files)

我怎么会去处理删除生成的文件加班吗?他们必须在实时数据的变化定期对删除。

How would I go about handling deleted the generated files overtime? They have to be deleted periodicly as the data changes in realtime.

感谢。

编辑:我现在意识到,在服务器上创建文件可能还需要4分钟... ...

edit: I realized now that creating the file on the server will probably also take 4 minutes...

推荐答案

我认为你是选择一个复杂的路线,当溶液很简单(虽然我可能会丢失一些要求)

I think you are selecting a complex route, when the solution is simple enough (Though I may be missing some requirements)

如果您生成一个excel,只需拨打一个asp页面,请执行以下操作:

If you to generate an excel, just call an asp page that do the following:

Response.clear
Response.AddHeader "content-disposition", "attachment; filename=myexcel.xls"
Response.ContentType = "application/excel"

'//write the content of the file
Response.write "...."

Response.end

这会启动浏览器中的下载过程,而不需要产生额外调用,JavaScript或任何

This will a start a download process in the browser without needing to generate a extra call, javascript or anything

请参阅这个问题有关格式,您的详细信息选择生成Excel中。

See this question for more info on the format you will choose to generate the excel.

由于托马斯更新的问题和真正的问题是,该文件需要4分钟,以产生,溶液可以是:

Since Thomas update the question and the real problem is that the file take 4 minutes to generate, the solution could be:


  1. 提供用户通过电子邮件发送文件(如果这是你的服务器或托管一个可行的解决方案)。

  1. Offer the user the send the file by email (if this is a workable solution in you server or hosting).

生成该文件异步,并让用户知道什么时候该文件生成完成(有一个Ajax调用,像这样做,当其他用户添加了一个答案)

Generate the file async, and let the user know when the file generation is done (with an ajax call, like SO does when other user have added an answer)

要在服务器上生成的文件

'//You should change for a random name or something that makes sense
FileName = "C:\temp\myexcel.xls" 
FileNumber = FreeFile
Open FileName For Append As #FileNumber

'//generate the content
TheRow = "...."
Print #FileNumber, TheRow




Close #FileNumber

删除临时文件生成

我使用清空临时文件夹的,我在服务器上运行,每天照顾一个免费的应用程序临时文件生成的。 (同样,这取决于你的服务器或主机上)

To delete the temp files generated
I use Empty Temp Folders a freeware app that I run daily on the server to take care of temp files generated. (Again, it depends on you server or hosting)

关于保障

生成使用随机数或GUIDS的光保护的文件。如果数据是敏感的,你需要下载从ASP页文件,但我认为你会在同样的问题再次...(等待4分钟下载)

About security
Generate the files using random numbers or GUIds for a light protection. If the data is sensitive, you will need to download the file from a ASP page, but I think that you will be in the same problem again...(waiting 4 minutes to download)

这篇关于与传统的ASP大文件的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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