我设计了一个 p2p 应用程序,它可以在没有服务器的情况下传输文件。一切正常。我可以在同行之间传输文件。但事实证明,如果文件大小大于 16mb(因为我可以传输的最大文件大小为 15810 kb)它不会传输到对等方。这是我正在使用的代码:
private function browseFile(farIds:String = ""):void {
fIds = farIds;
file = new FileReference();
file.addEventListener(Event.SELECT, selectHandler);
file.browse();
}
private function selectHandler(event:Event):void {
var btn = getChild("browseFile_" + fIds)
if (btn && btn.alpha) btn.alpha = 0.5;
file = FileReference(event.target);
file.addEventListener(ProgressEvent.PROGRESS, progressHandler);
file.addEventListener(Event.COMPLETE, completeHandler);
file.load();
}
private function progressHandler(event:ProgressEvent):void{
ExternalInterface.call("fileLoadProgress", event.target.name, event.bytesTotal, event.bytesLoaded)
}
private function completeHandler(event:Event):void{
ExternalInterface.call("onFileLoaded")
var fileData:Object = new Object();
fileData.file = event.target.data
fileData.name = event.target.name;
var btn = getChild("browseFile_" + fIds)
if (btn && btn.alpha) btn.alpha = 1;
sendSomeData(fileData, fIds, "receiveFile");
}
public function receiveFile(info:Object, peerID:String):void{
ExternalInterface.call("alert", "receivedFile")
}
private function sendSomeData(data,farIds:String,func:String = "receiveSomeData"):void{
for(var id:String in sendStreams){
sendStreams[id].send(func, data, myPeerID);
}
}
你能告诉我如何允许传输任何大小的所有文件吗?
感谢您的帮助!