AIR: securityError on OSX (but not on Windows) with URLStream()

社会主义新天地 提交于 2020-01-03 05:22:09

问题


I'm using URLStream to load a file from the harddisk (and I'd like to continue to use URLStream to do so). The file is located in "app-storage:/myfolder/myFile.zip"

so I use

var f:File = new File("app-storage:/myfolder/myFile.zip");
myStream.load(new URLRequest(f.nativePath));

on Windows this seems to work without problems - but on OS X the URLStream dispatches a SecurityErrorEvent.SECURITY_ERROR with the message:

Error #2032: Stream Error. URL: app:/Users/myUserName/Library/Preferences/MyAppName/Local%20Store/myfolder/myFile.zip

can someone explain me why this works on windows but not on OS X and how to resolve this issue?


回答1:


Good old, ambiguous error 2032!

You might want to try:

var f:File = new File(File.applicationStorageDirectory + "/myFolder/myFile.zip");

EDIT

My original comment was to use the File.applicationStorageDirectory property, and I still think that's a good idea. But it looks like that property boils down to the same string that you are using ... so perhaps the problem is that the location of the storage dir has changed and the file you are looking for is still in the original location? See link below.

End Edit

Note the comment here about a change made to this path in Air 3.3 for Mac OSX only. Even if this doesn't fix your problem, using this property should shield your code from future problems if the path changes or a different "schema" is needed for some other device/OS.



来源:https://stackoverflow.com/questions/11866761/air-securityerror-on-osx-but-not-on-windows-with-urlstream

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