本文介绍了如何解决Flash错误2176的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Flex应用程序中,用户需要能够上传和下载内容。但是,这个内容是访问受限的,我需要做一个权限检查,然后才允许上传/下载。用户单击一个链接,然后使用FileReference类选择一个文件。 FileReference类不附加cookie信息,所以我不能使用会话。

我想实现一个2步的过程,客户端首先ping服务器获取一次性使用令牌,然后以一次性使用令牌作为参数进行上传或下载。然而,这个计划正在被错误#2176挫败,这显然是FP10的安全修复,只允许在MouseEvent传播期间触发上传/下载。反正这个呢?

解决方案

我得到了这个。 c $ c><?xml version =1.0encoding =utf-8?>
layout =absolute
minWidth =955minHeight =600
creationComplete =creationCompleteHandler(event)>
< mx:Script>
import mx.controls.Alert;
导入mx.events.CloseEvent;
导入mx.events.FlexEvent;

protected function creationCompleteHandler(event:FlexEvent):void
{
Alert.show(现在您可以保存文件!,Test,Alert.OK | Alert .CANCEL,null,closeHandler);


保护函数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:应用程序>


In my Flex application, users need to be able to upload and download content. However, this content is access restricted, and I need to do a permissions check before allowing the upload/download. The user clicks a link, and then selects a file using the FileReference class. The FileReference class doesn't attach cookie information, so I can't use a session.

I want to implement a 2 step process where the client first pings the server to get a one-time-use token, and then does the upload or download with the one-time-use token as a parameter. However, this plan is being foiled by error #2176, which is apparently a security fix to FP10, that only allows uploads/download to be triggered during a MouseEvent propogation. Anyways around this?

解决方案

I got workarround for this 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>

这篇关于如何解决Flash错误2176的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 18:57