Flash/Flex crossdomain issue - using BitmapData.draw() for image from AWS S3 results in SecurityError: Error #2122: Security sandbox violation

自闭症网瘾萝莉.ら 提交于 2019-12-07 22:01:27

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/9217973/flash-flex-crossdomain-issue-using-bitmapdata-draw-for-image-from-aws-s3-res

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