How to get around Flash error 2176

夙愿已清 提交于 2019-12-22 13:11:07

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/2859336/how-to-get-around-flash-error-2176

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!