在我的 Flex 应用程序中,用户需要能够上传和下载内容。但是,此内容受到访问限制,我需要在允许上传/下载之前进行权限检查。用户单击链接,然后使用 FileReference 类选择文件。 FileReference 类不附加 cookie 信息,因此我无法使用 session 。
我想实现一个两步过程,其中客户端首先 ping 服务器以获取一次性 token ,然后使用一次性 token 作为参数进行上传或下载。然而,这个计划被错误 #2176 挫败,这显然是 FP10 的安全修复,只允许在 MouseEvent 传播期间触发上传/下载。不管怎样?
最佳答案
我找到了解决方法 here.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
minWidth="955" minHeight="600"
creationComplete="creationCompleteHandler(event)">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
protected function creationCompleteHandler(event:FlexEvent):void
{
Alert.show("Now you can save the file!", "Test", Alert.OK|Alert.CANCEL, null, closeHandler);
}
protected function closeHandler( event:CloseEvent ):void
{
var fileReference :FileReference;
if ( event.detail == Alert.OK )
{
fileReference = new FileReference();
fileReference.save("http://www.bogdanmanate.com", "test.txt");
}
}
]]>
</mx:Script>
</mx:Application>
关于apache-flex - 如何解决 Flash 错误 2176,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2859336/