4 Replies Latest reply on Sep 18, 2011 3:20 PM by Josip Pokrajcic

    Saving to iOS filesystem


      I'm wondering if people are having as difficult of a time as I am saving a file to the iOS filesystem (iPad2).


      Basically, what I'm trying to do is create a folder where my app saves pictures that the camera takes (I don't want it on the generic camera roll).


      Here is my save image function. "snapData" is a BitmapData file created with the camera (I've confirmed that works). The problem seems to be occuring below.


      protected function saveImage(event:MouseEvent):void

                      var jpgenc : JPEGEncoder = new JPEGEncoder();
                      var imgByteArray : ByteArray = jpgenc.encode(snapData);
                      var filename : String = "test.jpg"
                      var fl:File = File.documentsDirectory.resolvePath("/Photos/" + filename);
                      var fs:FileStream = new FileStream();



      I've also tried a few different methods, but I just can't seem to save my file anywhere on the filesystem. I've looked extensively online as well, but I assume because iOS is fairly new for flex, there are fewer example....


      Any help would be greatly appreciated.


      Thank you!

        • 1. Re: Saving to iOS filesystem
          markerline Level 4

          See if you can download for a small fee the app called FileApp Pro in the Apple App Store.  Then use the directories in that app to try to acc

          ess their folder structure in your Flex app.


          It's worth a shot.  (Right now I can't troubleshoot because my iPad 1 bricked out due to the expiration of my iOS5 beta.  And for several reasons I can't upgrade until the final public release of iOS5 is available.)

          1 person found this helpful
          • 2. Re: Saving to iOS filesystem
            fufonzo Level 1

            Thank you for that. I will definitely have a look into getting that app.


            My issue was that it wasn't saving at all. It would jump to "error".


            I just realized that it seems as though it may just have been an issue with my putting a '/' in front of my path.


            var fl:File = File.applicationStorageDirectory.resolvePath("/Photos/7.jpg");


            I took it out (as well as the filename) and it stopped erroring out.


            var fl:File = File.applicationStorageDirectory.resolvePath("Photos/");


            I'm still playing around with it but hopefully, i'll have it resolved soon. Will post the final answer if I manage to figure it out.

            • 3. Re: Saving to iOS filesystem
              fufonzo Level 1

              Alright, so that was my mistake....urgh....


              var fl:File = File.applicationStorageDirectory.resolvePath("/Photos/7.jpg");


              Should have been:


              var fl:File = File.applicationStorageDirectory.resolvePath("Photos/7.jpg");

              • 4. Re: Saving to iOS filesystem
                Josip Pokrajcic

                did you manage this to work in the end? i tried to do the same thing as you did but i couln't find saved file in that directory