我有一个应用程序,它下载几个大的二进制文件并将它们保存到磁盘上。在某些机器上,它工作得很好,而在其他一些机器上,每隔一段时间,下载就会完成99.9%,并且URLStream对象不会触发Event.COMPLETE
这与此处出现的问题几乎完全相同:
Why does URLStream complete event get dispatched when the file is not finished loading?
我试过使用其中一个答案中描述的“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 );发布于 2016-04-15 21:50:33
Imo,这是一个注定要失败的代码,你故意放弃对正在发生的任何事情的控制,只是假设一切都会自己工作并运行良好。我在使用URLStream类时从来没有遇到过任何问题,但以下是我基本上从不做的事情:
https://stackoverflow.com/questions/36580439
复制相似问题