Flash / Flex crosstalk issue - using BitmapData.draw () for an image from AWS S3 results in a SecurityError error: Error # 2122: security sandbox violation

I am using BitmapData.draw () in a DisplayObject that includes an image from my AWS S3 bucket. The image loads fine in swf when I set the URL of the S3 image as the source for the 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 tried to put the following crossdomain.xml file into my S3 bucket cord 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> 
+2
source share
1 answer

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 must be located in the root folder of the domain and you do not have access to the root folder s3.amazonaws.com , you cannot manage the crossdomain.xml file if you use the first method

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

+3
source

Source: https://habr.com/ru/post/907419/


All Articles