Sandbox violation while accessing image files in Flex 4 - apache-flex

I'm working on an image gallery application. Very frequently I'm getting Sandbox violation Error like Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.. Some times its raising by cleaning the project. Every time I'm using my application's backup and updating and then the error is raising. Though I'm accessing local image files, getting error. I'm using try-catch to catch the location but no use. How to get rid of this problem. Any help is appreciated.

If u Clean the project It Will remove all your
assets files in the bin-debug folder and it will be
recreated during the Build.Some times the build wont
creates the file properly i think that time you are
getting the error.
At most avoid cleaning.It may also happens by the
out dated flash player version.
It may also happens by the following ways,
incorrect path to the upload file script - check relative and absolute paths
a incorrect location for the files to be stored on the server specified inside server-side upload script - check path is correct and permissions are correct
file is too large so server rejects it - check max file size
there is no space on the server to save the file - check server hard drive space
your actionscript handler is going out of scope because it's declared locally,
etc - create a strong event listener or declare the file reference on the class
Check one of the option and Comment is must.

About loading local images. You should check and fix Flash Player trust file for your SWF as described here. Flash Builder done it automatically but who knows…
About problem with loading images in web it can be problem related to loading images from other domain which hasn't proper crossdomain.xml file. If so you should use some kind of proxy on your server.
If you're loading files from your own domain maybe this deployment checklist can help you. Also you can use some debugging proxy like Charles to see the real queries and responses.

Related

strange issue when uploading file via asp.net, vs manually via FTP

I have a form in ASP.Net MVC, which allows you to upload a file. The file is saved to a location on the server. For example, if the domain is www.test-domain.com, and the local path is c:\websites\test-domain.com\, the image is stored in /uploads/File/image.jpg.
When I try to access this url http://www.test-domain.com/uploads/File/image.jpg, I get redirected to the forms loginUrl="XXXX" path in web.config. To test, I removed the web.config entirely, and accessed the file. This time round, I get a 401 - Unauthorized: Access is denied due to invalid credentials.
I then uploaded another file via FTP this time, to http://www.test-domain.com/uploads/File/image2.jpg. This one can be accessed without any problem. I even tried download image.jpg as saved via Asp.Net, delete the file on server and re-upload the same exact file by FTP and it worked again!
It seems by FTP is working, while via Asp.Net somehow there are some access / authorisation requirement. I do have authentication set in Asp.Net, but I removed the entire web.config file, and I still got an error.
Any ideas?
I've found out why this was happening, though it is totally unrelated to what I thought it was in the beginning. I am uploading an image and resizing it. I've looked further in the code, and for some reason I was creating an image in the temporary windows folder, and then moving it to the actual location using File.Move.
It seems that the security permissions created are different, than if I had to create the file directly in the final folder. I've updated the code to create the image directly in the actual folder, and this is working fine.
Reference: http://blogs.msdn.com/b/oldnewthing/archive/2006/08/24/717181.aspx

Is there a way to download a PHP/ASP/whatever source code without processing it, as plain text?

Suppose the URL http://example.com/test.php. If I type this URL on the browser address bar, the PHP code is executed, and its output is returned to me. Fine. But, what if instead of executing it, I wanted to view it's source as plain text. Is there a a way to issue such request?
I believe that there must be some way, and my concern is that some outsider could retrieve sensitive code, such as configurations file, by guessing it's location. For example, Joomla instalations have a configuration.php on it's root folder. If someone retrieves such file as plain text, then these database credentials have been seriously compromised. Obviously, this could be prevented with proper permissions, but it's just too common to just issue 0777 as everything permissions and forgetting about access denials.
For PHP: if properly configured, there is no way to download it. File permissions won't help either way, as the webserver needs to be able to read the files, and that's the one serving contents. However. a webserver can for instance be configured to serve them with x-httpd-php-source, or the PHP/webserver configuration may be broken. Which is why files which don't need direct access (db config, class definitions, etc.) should be outside the document root, so there is no way those files will get served by accident even when the webserver config is incorrect / failing. If your current hoster does not allow you to store files outside the document root, switch hosting a.s.a.p.
There is a way to issue such request that downloads the source code of http://example.com/test.php if the server is configured to provide a URL to do so. Usually it isn't, so usually there is no way to issue such a request.

Excel upload in flex 3

am trying to upload excel file using filereference
however when uploading it is throwing this error
Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type.
Action script error occured
after continue it is uploading the file but why that error is coming?
Thanks
contentLoaderInfo is key
loader.contentLoaderInfo.addeventListener( IOErrorEvent.IO_ERROR , someIOerrorCallBack )
Check out http://scottrockers.com/blog/resources/flash-information/workaround-solution-to-flash-error-2044-unhandled-securityerror-and-error-2048-security-sandbox-violation, but like JAX & Lee said, we need a lot more info. Are you trying to load the excel file from your computer, from a seperate domain, from localhost, from 127.0.0.1? Easiest way is if your trying to load it from a localhost url, that should work. If it's a file on disk, check your security settings http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html and enabled the directory where the file resides. If your loading it from some other domain, you need to take other precautions like a crossdomain.xml on that domain.
Are you using the .load() method of FileReference? If so, don't. Just do the .browse() method and when the selected event is triggered, have FileReference go ahead with the .upload(). The only reason you would need to use .load() is if your Flex client needs to read the bytes.

Where would I keep my .txt files for inclusion in a Flex app?

I'm working on a flex app, and I have Flash & AS3 experience up to now. I have text file I need to request using URLLoader, so I placed it in the same directory as the SWF
deploy > maps > map1.txt
but when run the SWF I get the following error
*** Security Sandbox Violation ***
SecurityError: Error #2148: SWF file file:///Users/him/Documents/Clients/Geekery/Bounce/deploy/Bounce.swf cannot access local resource /maps/map1.txt. Only local-with-filesystem and trusted local SWF files may access local resources.
at flash.net::URLStream/load()
at flash.net::URLLoader/load()
at com.geekery.Bounce::BounceMap()
at Bounce/loadMap()
at Bounce()
Which seems odd to me. Is there a special place I should be keeping files like this? Or is there some way I can allow files to be loaded form the same directory as the SWF?
Are you using a relative or absolute url? Have you tried loader.load( new URLRequest( 'maps/map1.txt' ) ) ?
If the file is static, you can use the #Embed tag to do this. See this example.
What you need is a crossdomain.xml to set the permissions for the .swf application on the same server. More info at below links
Cross-domain policy file specification
loadPolicyFile()
If this is not really what you are looking for then you can just go for the [Embed] solution.

Loading a video from the local file system

I have a swf that is run from C:/ in the browser instead of a server (long story) and that swf loads a video that it located at ../../videos/video in relation to that swf.
Problem is, When I run it in Flex, everything is cool. Running locally, it can't find the file (not a security error) and is throwing a connectionError.
Any ideas?
NOTE: This seems to be a Windows specific problem, it's running on my mac with the same security settings just fine.
Flex Builder has a file that it adds all of your bin directories to in order to allow the debug player to get around the local security restrictions.
Here's a blog post on the subject.
Essentially Flexbuilder tells Flash that it should trust the bin folder... if you do a search on your development machine for the file flexbuilder_plugin.cfg, you should find it in a folder called FlashPlayerTrust in roughly the same area you normally find SharedObject files. If you open this file in a text editor, you should see pretty much every path to every bin folder for every flex project you have ever worked on. And suddenly everything gets so much clearer.
You can do as fenomas suggests and add any directory to your trusted list. You can also follow the advice from the above blog post.
So I created a new file and placed it next to this flexbuilder_plugin.cfg file, and called it MyProggy.cfg. Flash is configured to read in all files in this folder and parse all paths out of it, and any applications run from these paths will be considered "localTrusted" and will act as they would when run from Flexbuilder. Inside this text file I put one line: "c:\program files\my proggy" and saved it. I then had to restart Firefox for the change to take effect. I also had added a text label to my application and bound the text property to {Security.sandboxType}.
I would suggest getting HTTPFOX for Firefox which is a sniffer. Then you can see what is failing. In my own search I found that FLV's are always relative to the SWF, even when loaded on the WEB. Every asset that I have loaded is relative to the index.html file except for FLV's which always remain relative to the SWF. Being able to watch the data flowing, or attempting to flow to your site is invaluable.
This also explains why some people have no issue loading thing locally but then run into problems on the web. If their html file that is loading the swf is in a different location than the swf then every asset other than FLV's have a different relative path when viewed online then they do when viewed locally.

Resources