6 Replies Latest reply on Jun 18, 2009 11:35 PM by Yogesh061

    AIR 1.5 - Can't Access Local Network URIs?

    Joel HOoks Level 1
      private static const ROOT_PATH_TO_SERVER_TEMP:String = "\\\\server\\share\\queue\\temp_images\\"

      Up until the 1.5 update, this worked great. Now it gives me :

      Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.

      Which implies that I do not have permission to access the resource. I do, but AIR isn't allowing it to happen. This has COMPLETELY hosed my application for our company's CMS.

      Any thoughts?
        • 1. AIR 1.5 - Can't Access Local Network URIs?
          KenSATX
          I have a similar issue, this code:
          var folderPath = new air.File("\\\\server\\share\\folder"); //folder that needs to be created
          folderPath.createDirectory();

          GENERATES
          Error: Error #3003: File or directory does not exist.
          at flash.filesystem::File/createDirectory()

          Note that if the folder actually exists the AIR file object recognizes that (folderPath.exists comes back as true).

          This code worked in 1.1. Furthermore if I map the share and use the drive letter instead (var folderPath = "T:\\folder", it works in 1.5. I'm guessing this is a security issue? Not sure why though considering I have admin access on the share and the folder via NTFS.

          Any help would be greatly appreciated as several of our tools are AIR based and ALL our files are accessed via UNC shares. So essentially we are unable to upgrade to 1.5 until we find a way to address this.

          Thanks!
          Ken

          • 2. Re: AIR 1.5 - Can't Access Local Network URIs?
            KenSATX Level 1
            After some further troubleshooting I have isolated that the only issue is the creation of a directory on a UNC share (\\server\\share\\folder). I can read/edit/create files on a UNC share, but I can not create a directory.

            This worked in 1.1 and now does not in 1.5. I have confirmed I have both share and NTFS level rights to create folders. If I map the share to a drive, it works.

            Does anyone have any information on this?

            Thanks!
            Ken
            • 3. Re: AIR 1.5 - Can't Access Local Network URIs?
              Joel HOoks Level 1
              @KenSATX

              Thank you for testing this further. This is the same issue that I am having. Files are fine, but making directories == NOJOY
              • 4. Re: AIR 1.5 - Can't Access Local Network URIs?
                KenSATX Level 1
                I have implemented a work around for this issue. If the user is running 1.5, I create the folder in their local storage directory and then move it to the destination UNC path. That works. I pasted the static method I'm using to do this below:

                FileUtil.createFolder = function(path,overwrite) {
                var runtimeVersion = air.NativeApplication.nativeApplication.runtimeVersion;
                var runtimeArray = runtimeVersion.split(".");
                var useWorkaround = false;
                //1.5.0.7220 - bad version
                //do workaround for 1.5 if UNC path
                if ((runtimeArray[0] == "1") && (runtimeArray[1] == "5") && (path.substr(0,2) == "\\\\")) {
                useWorkaround = true;
                }
                var folder = new air.File(path);
                if ((!folder.exists) || (overwrite)) {
                if (folder.exists) {
                folder.deleteDirectory(true);
                }
                if (useWorkaround) {
                var storeFolder = air.File.applicationStorageDirectory;
                var folderName = FileUtil.getLastFolder(path);
                var tempFolder = storeFolder.resolvePath(folderName);
                var parentFolder = folder.parent;
                if (!parentFolder.exists) {
                FileUtil.createFolder(parentFolder.nativePath,false);
                }
                if (tempFolder.exists) {
                tempFolder.deleteDirectory(true);
                }
                tempFolder.createDirectory();
                tempFolder.moveTo(folder,true);
                }
                else {
                folder.createDirectory();
                }
                }
                }

                FileUtil.getLastFolder = function(path) {
                path += "";
                for (var i=path.length-1;i>-1;i--) {
                var tmpChr = path.substr(i,1);
                if ((tmpChr == "/") || (tmpChr == "\\")) {
                return path.substr(i+1);
                }
                }
                return "";
                }

                You can use this method instead of createDirectory(). So for example, newFolder.createDirectory() would be FileUtil.createFolder(newFolder.nativePath,true).

                Hope this helps.

                Ken
                • 6. Re: AIR 1.5 - Can't Access Local Network URIs?
                  Yogesh061

                  Hi,

                   

                  I think there is some problem with the Flex Builder in the debug mode I was also experincing the same problem. But after releasing the AIR file of project the simple "createDirecroty()" function worked well for me.

                   

                  I hope this helps.

                   

                  Yogesh