Flex 3 文件下载 - 没有 URLRequest [英] Flex 3 file download - Without URLRequest
问题描述
我的 Flex 客户端应用程序从后端(RemoteObjects、BlazeDS、Spring)获取了一些数据.客户已获得所需的所有数据,现在需要将一些信息以 CSV 格式保存并可供下载.
My Flex client app has got some data from the back end (RemoteObjects, BlazeDS, Spring). Client has got all the data it needs, it now needs to put some information in a CSV format and make it available for download.
为此使用 Flex 3.有什么想法吗?
Using Flex 3 for this. Any ideas?
谢谢,斯里
推荐答案
如果您正在为 Flash Player 10 进行编译,那么您可以调用 FileReference.save()
函数来保存到本地文件-系统:
If you are compiling for Flash Player 10 then you can call the FileReference.save()
function to save to the local file-system:
请务必注意此部分:
在 Flash Player 中,您只能成功调用此方法以响应用户事件(例如,在鼠标单击或按键事件的事件处理程序中).否则,调用此方法会导致 Flash Player 抛出错误异常.此限制不适用于应用程序沙箱中的 AIR 内容.
In Flash Player, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception. This limitation does not apply to AIR content in the application sandbox.
如果您无法为 Flash Player 10 进行编译,唯一的另一种选择是将数据发送到服务器并让用户从那里以 CSV 格式下载它.
The only other alternative if you can't compile for Flash Player 10 is to send the data to the server and have the user download it from there as a CSV.
您可以使用 FileReference.download()
以类似于 save()
的方式执行此操作:http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/flash/net/FileReference.html#download()
You can do this with the FileReference.download()
in a simlar manner to save()
:
http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/flash/net/FileReference.html#download()
这篇关于Flex 3 文件下载 - 没有 URLRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!