我想优化文件到服务器的上传 - 最好的方法是什么?
我有一个 Rails 应用程序,它执行以下(目前是线性的)过程:
(1)用户通过 HTTP 上传文件并在标准 HTML 页面上使用标准上传表单 (2) 文件上传到 apache 服务器(与托管应用程序的服务器相同) (3)服务器将文件上传到远程存储服务(将此存储称为1) (4) 完成(3) 后,用户会自动进入其他页面。
在上传文件时,用户会看到进度条等。
现在问题: - (1) -> (4) 对于大文件需要相当长的时间(因为过程(2)和(3)需要一段时间)并且浏览器在移动到(4)之前等待服务器响应(即来自服务器的响应指示( 3)已完成)。
有什么办法可以加快速度(1)-> (4)。我不介意文件是否加载到存储 1 并在后台加载到服务器上,同时允许用户浏览网站上的其他页面。
现在额外的想法是 - 如果需要,文件上传到的服务器(我们称之为服务器 1)可以与托管服务器(服务器 2)不同。
任何想法表示赞赏。
I have a rails app that does the following (at the moment linear) process:
(1) User uploads a file via HTTP and a standard upload form on a standard HTML page
(2) The file is uploaded to an apache server (same server as the one hosting the app)
(3) The server uploads the file to remote storage service (call this storage 1)
(4) When (3) is done, the user is taken automatically to some other page
While the file is being uploaded the user sees a progress bar etc.
Now question: - (1) -> (4) takes quite a long time for large files (because processes (2) and (3) take a while) and the browser waits for a server response before moving to (4) (i.e. a response from server indicating the completion of (3) have completed).
Is there any way of speeding up (1) -> (4). I don't mind if the file loads into storage 1 and onto the server in the background while the user is allowed to browse other page on the site.
Now the additional thought is - the server to which the file is uploaded to (lets call it server 1) can be different to the hosting server (server 2) if necessary.
Any ideas appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件上传到服务器后,立即将其移动。让服务器本身使用“延迟作业”之类的方法将文件移动到“存储 1”,然后通知用户(使用电子邮件等系统)该文件现在可供下载。
As soon as the file is uploaded to the server, move them on. Let the server itself handle the moving the file to "storage 1" using something like Delayed Job and then notify the user (using a system such as email) that the file is now available to be downloaded.