ajax 使用进度条将文件直接上传到 S3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/478799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upload File Directly to S3 with Progress Bar
提问by John Boker
Relating to this question, Upload files directly to Amazon S3 from ASP.NET application, is there any way to do this and have a progress bar?
关于这个问题,从 ASP.NET 应用程序直接将文件上传到 Amazon S3,有没有办法做到这一点并有进度条?
---- EDIT ----
- - 编辑 - -
Two days later and still no luck with a direct way. Found one thing that looks promising but not free: http://www.flajaxian.com/
两天后,仍然没有直接方式的运气。发现一件事看起来很有前途但不是免费的:http: //www.flajaxian.com/
Uses flash to upload directly to S3 with a progress bar.
使用 flash 通过进度条直接上传到 S3。
采纳答案by Blaine
I'm looking for a solution as well. Maybe this will be of some help,
我也在寻找解决方案。也许这会有所帮助,
From AWS Dev CommnityBut in many languages (PHP, Java), for big files, you have to use streams through which the language environment will take chunks of your big file one after the other (in order to fill up central memory with huge amount of data for the http POST of S3 needed for the upload.
The nice thing about stream is that they have a callback called whenever the next chunk is read for to further PUT (in the https sense) data to S3. You can use this callback to compute and display the progress on the client UI.
See the doc of libcurl to see in details how all this works.
来自 AWS Dev Commnity但是在许多语言(PHP、Java)中,对于大文件,您必须使用流,通过这些流,语言环境将一个接一个地获取大文件的块(为了填充大量中央内存)上传所需的 S3 的 http POST 数据。
流的好处是,每当读取下一个块时,它们都会调用回调,以进一步将 PUT(在 https 意义上)数据发送到 S3。您可以使用此回调计算并在客户端 UI 上显示进度。
请参阅 libcurl 的文档以详细了解所有这些是如何工作的。
Update: It looks like there are two straightforward options.
更新:看起来有两个简单的选择。
I personally hate using 3rd party extensions (Flash, Java) to make an app function, but I haven't found another way.
我个人讨厌使用 3rd 方扩展(Flash、Java)来制作应用程序功能,但我还没有找到另一种方法。
回答by user250906
html5 javascript can allow you to do it, if you don't mind lack of browser support (Firefox and Chrome only as of this post_ Example here: https://developer.mozilla.org/en/Using_files_from_web_applications
html5 javascript 可以让你这样做,如果你不介意缺乏浏览器支持(Firefox 和 Chrome 仅在这篇文章中_示例:https: //developer.mozilla.org/en/Using_files_from_web_applications
This isn't specific to AWS, but may help you get closer.
这并非特定于 AWS,但可以帮助您更接近。
回答by phirschybar
Another approach is to use something like Uber Uploader (http://uber-uploader.sourceforge.net/) which is a perl / php hybrid solution with a progress bar. You would simply upload the files to your server and then have your server FTP them in the background to the final destination. It is an extra step but it gives you some time to do any processing / encoding / etc. that you may need to do before sending to S3.
另一种方法是使用像 Uber Uploader ( http://uber-uploader.sourceforge.net/) 这样的东西,它是一个带有进度条的 perl / php 混合解决方案。您只需将文件上传到您的服务器,然后让您的服务器在后台将它们通过 FTP 传输到最终目的地。这是一个额外的步骤,但它给了你一些时间来做任何处理/编码/等,你可能需要在发送到 S3 之前做这些。

