我有一个应用程序正在下载几个大型二进制文件并将它们保存到磁盘。在某些机器上它工作正常,而在其他一些机器上,每隔一段时间,下载将进行到 99.9% 完成,并且 URLStream 对象不会触发 Event.COMPLETE
这与此处出现的问题几乎相同:
为什么在文件未完成加载时会调度 URLStream 完成事件?
我尝试使用答案之一中描述的“Cache Bust”方法,但仍然没有骰子。
任何帮助,将不胜感激。
这是一些示例代码,可帮助说明我正在尝试做的事情:
var contentURL:String = "http://some-large-binary-file-in-amazon-s3.tar";
var stream:URLStream = new URLStream();
stream.addEventListener(Event.COMPLETE, function(e:Event):void{
//This should fire when the file is done downloading
//On some systems this fails to fire once in a while
//On other systems it never fails to fire
});
stream.addEventListener(ProgressEvent.PROGRESS, function(pe:ProgressEvent):void{
//Write the bytes available in the stream and save them to disk
//Note that a download will reach 100% complete in terms of total progress but the 'complete' event might still not fire.
});
var urlRequest:URLRequest = new URLRequest(contentURL);
//Here we might add some headers to the URL Request for resuming a file
//but they don't matter, the 'Event.COMPLETE' will fail to fire with our without
//these headers
addCustomHeaders( urlRequest );
stream.load( urlRequest );