开发者

How can I download a file not using File reference Object in Flex

I need to downlo开发者_Python百科ad a file without using FileReference Object in Flex. In fact I don't want to show the Dialog Box while ask for download. I just want to download in my default location. How can do achieve this.

Thanks, Rejeev.


private var fileStream:FileStream;

private function downloadFile():void
{
    var file:File=File.desktopDirectory.resolvePath('fileName');
    fileStream=new FileStream();
    fileStream.open(file, FileMode.WRITE);

    var urlLoader:URLLoader=new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, onDownloadedComplete);
    urlLoader.dataFormat=URLLoaderDataFormat.BINARY;
    urlLoader.load(new URLRequest('downloadLink'));
}

private function onDownloadComplete(evt:Event):void
{
     fileStream.writeBytes((evt.target).data);
     fileStream.close();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜