いくつかの大きなバイナリファイルをダウンロードしてディスクに保存するアプリケーションがあります。一部のマシンでは正常に動作し、他のマシンではダウンロードが99.9%完了し、URLStreamオブジェクトはEvent.COMPLETEを起動しません。URLStreamでEvent.COMPLETEが発生しないことがあるのはなぜですか?
これは、ここに表示される問題とほとんど同じです。
Why does URLStream complete event get dispatched when the file is not finished loading?
私は答えたが、まだありませんサイコロの1で説明した「キャッシュバスト」メソッドを使用して試してみました。
ご協力いただければ幸いです。ここで
は私がやろうとしています何を説明するのに役立ついくつかのサンプルコードです:
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);
コードはどこですか? – BotMaster
コードサンプルを含むように投稿を更新しました。 – Phil
** "一部のシステムではこれはしばらくしてから失敗します...他のものでは決して失敗しません..." *まず、失敗したシステムをチェックします。それはインターネット接続の問題ですか(例:大きなダウンロードをカットするものなどありますか?)あなたのコードに間違いがあるのではなく、ハードウェア/ネットワークの問題のようです(そうでなければ、すべてのシステムでうまく動作しません)。 –