如何下载文件到默认的目录中没有的Flex /空气坡平的一个选项窗口? [英] how to download files to a default dir without poping an option window in Flex/Air?
问题描述
我正在写使用Flex /空气的应用程序,我需要它不支持air.how一个功能,将文件下载到默认目录没有弹出window.i试图使用FTP而不是HTTP,但发现我能解决这个问题?
I'm writing a app with Flex/air,and i need a function that downloading files to the default dir without a pop-up window.i tried to use ftp instead of http but found it's not supported by air.how can i solve this problem?
推荐答案
这应该有可能在空气中。我不知道,如果有一个直接的API方法,但你应该能够加载字节到内存中,然后冲洗成一个文件。在使用文件伪伪code和的FileStream :
This should be possible in AIR. I don't know if there's a direct API approach, but you should be able to load the bytes into memory and then flush them into a file. In pseudo-pseudo-code using File and FileStream:
// get the bytes
var loader:URLLoader = new URLLoader();
loader.load("http://www.stackoverflow.com");
...
var bytes:ByteArray = loader.data;
// get the file in the correct location
var f:File = File.documentsDirectory.resolvePath("myfile.txt");
// write the file
var fs:FileStream = new FileStream(f, FileMode.WRITE);
fs.writeBytes(bytes);
fs.close();
有href="http://www.google.com/search?q=using+file+filestream+air" rel="nofollow">几个例子的都来看看一个
There are a few examples out there to look at.
这一切都不是由于安全限制@viatropos建议可能在Flash播放器。
None of this is possible in Flash Player because of the security limits @viatropos suggests.
这篇关于如何下载文件到默认的目录中没有的Flex /空气坡平的一个选项窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!