function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
LeonardLeonard 

Can't download Attachments from Flex. Security error.

I followed this example for downloading Attachments from Flex

 

 http://blog.nitrogenlabs.com/2008/10/flex-getting-attachments-from.html

 

And I'm getting a Sandbox error.

 

 

*** Security Sandbox Violation *** Connection to https://na2.salesforce.com/servlet/servlet.FileDownload?file=MyFile halted - not permitted from https://c.na2.visual.force.com/resource/1266428442000/MyResource Error #2044: Unhandled SecurityErrorEvent:. text=Error #2048: Security sandbox violation: https://c.na2.visual.force.com/resource/1266428442000/MyResource cannot load data from https://na2.salesforce.com/servlet/servlet.FileDownload?file=MyFile. at x at x Error: Request for resource at https://na2.salesforce.com/servlet/servlet.FileDownload?file=MyFile by requestor from https://c.na2.visual.force.com/resource/1266428442000/MyResource is denied due to lack of policy file permissions.

 

If I grab the url of the attachment and paste it directly into the browser, I can download the file with no authentication challenge or errors.

 

 

 

werewolfwerewolf

It's a cross-domain scripting error -- your Flex app must be running in a Visualforce page.  It might fix it if you alter the URL of the file such that the domain is the same, like

 

https://c.na2.visual.force.com/servlet/servlet.FileDownload?file=MyFile

 

Not sure if you can really get to it with that kind of URL but it's worth a try.

Chirag MehtaChirag Mehta

I am also facing same issue, Any solutions found yet?

Nick34536345Nick34536345
looking at example code linked originally, are you using the "retrieve" method or the URLRequest method? presumably the former should work, and the latter will always have this cross domain problem