本文介绍了闪光/ Flex的跨域问题 - 在引发SecurityError使用的BitmapData.draw()图像从AWS S3的结果:错误#2122:安全性违规的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个DisplayObject,其中包括从我的AWS S3存储的图像使用的BitmapData.draw()。罚款swf的图像加载当我设置的S3图像URL作为源一Image对象,但是当我在上面使用的BitmapData.draw(),它给了我这个错误:

引发SecurityError:错误#2122:安全沙箱冲突:的BitmapData.draw:的https://www.example .COM / Example.swf 不能访问 https://s3.amazonaws.com /example-images/example.jpg ,需要的策略文件,但将checkPolicyFile标志未设置时加载此媒体。

AS code:

  VAR bmpd:的BitmapData =新的BitmapData(objectToDraw.width,objectToDraw.height);
bmpd.draw(objectToDraw);
 

我试图把下面的crossdomain.xml文件在我的S3存储桶根本无济于事:

 < XML版本=1.0><!DOCTYPE跨域政策体系http://www.macromedia.com/xml/dtds/cross -domain-policy.dtd>
<交域政策>
<允许存取来自域=*/>
< /跨域策略>
 

解决方案

有两种方式来访问S3文件:

  • s3.amazonaws.com/ [斗名称] /file.ext
  • [斗名称] .s3.amazonaws.com / file.ext

由于crossdomain.xml文件需要在域的根文件夹,您没有访问 s3.amazonaws.com 的根文件夹,你不能,如果你使用的是第一种方法控制​​的crossdomain.xml 文件

如果您使用的是第二种方法,你可以把一个的crossdomain.xml 文件在你的水桶的根文件夹,它会通过正确的Flash播放器中使用。

I am using BitmapData.draw() on a DisplayObject that includes an image from my AWS S3 bucket. The image loads fine in the swf when I set the S3 image URL as the source for an Image object but when I use BitmapData.draw() on it, it gives me this error:

"SecurityError: Error #2122: Security sandbox violation: BitmapData.draw: https://www.example.com/Example.swf cannot access https://s3.amazonaws.com/example-images/example.jpg. A policy file is required, but the checkPolicyFile flag was not set when this media was loaded."

AS code:

var bmpd:BitmapData = new BitmapData(objectToDraw.width,objectToDraw.height);
bmpd.draw(objectToDraw);

I have tried putting the following crossdomain.xml file in my S3 bucket root to no avail:

<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
解决方案

There are two ways to access files on S3:

  • s3.amazonaws.com/[bucket name]/file.ext
  • [bucket name].s3.amazonaws.com/file.ext

Since the crossdomain.xml file needs to be in the root folder of the domain, and you don't have access to the root folder of s3.amazonaws.com, you can't control the crossdomain.xml file if you are using the first method

If you are using the second method, you can put a crossdomain.xml file in the root folder of your bucket and it will be used correctly by the Flash Player.

这篇关于闪光/ Flex的跨域问题 - 在引发SecurityError使用的BitmapData.draw()图像从AWS S3的结果:错误#2122:安全性违规的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:08