0

I have an action script function in a file which sends a pdf file as binary content to a servlet as shown below.

private function savePDF(pdfBinary:ByteArray, urlString:String):void{

            try{
                Alert.show("in savePDF urlString" +urlString);
                //result comes back as binary, create a new URL request and pass it back to the server
                var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

                var sendRequest:URLRequest = new URLRequest(urlString);
                sendRequest.requestHeaders.push(header);
                sendRequest.method = URLRequestMethod.POST;
                sendRequest.data = pdfBinary;

                Alert.show("in savePDF calling sendToURL"); 

                sendToURL(sendRequest);
            }catch(error:*){
                Alert.show("in savePDF err" +error);    
                trace(error);
                }
            } 

This code works fine in flashplayers versions like 10,11,13

But fails in flashplayers of higher versions like 14.0.0.126 or above.

I get the following error

SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().

Any suggestions on how to resolve this ?

3
  • This is a known issue caused by a security update in a recent version of Flash Player; see forums.adobe.com/thread/1521470 and bugbase.adobe.com/index.cfm?event=bug&id=3759971. @CyanAngel's answer will let you send your request without being blocked by this security check. Commented Nov 10, 2014 at 20:58
  • Is there any issue with "passing data to swf file using FlashVars variable" in recent version of Flash Player ? I get all the variables as null Commented Nov 11, 2014 at 5:57
  • Not that I know of. However, it can be tricky to get right if you're not sure how to pass in variables. Commented Nov 11, 2014 at 8:40

1 Answer 1

2

You could try using a URLLoader instead of sendToURL()

Alert.show("in savePDF urlString" +urlString);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

var sendRequest:URLRequest = new URLRequest(urlString);
sendRequest.requestHeaders.push(header);
sendRequest.method = URLRequestMethod.POST;
sendRequest.data = pdfBinary;

Alert.show("in savePDF calling URLLoader"); 

var loader:URLLoader = new URLLoader();
loader.load(sendRequest);
Sign up to request clarification or add additional context in comments.

2 Comments

I get the following error if I use URLLoader Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: <my URL>
You may need to set up a cross domain policy, see : stackoverflow.com/questions/5157089/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.