2 Replies Latest reply on Aug 20, 2008 10:17 AM by justria

    filesystem access

      we want to have our digital camera write a file to a directory each time a photo is taken. then we
      want to have our flex app be able to detect that the new image was placed in the directory and load
      it into the flex app. is there any way to do this? i saw that flex doesn't provide for threads so how
      could i watch the directory? is it possible to access the filesystem if i want to run in the web browser
      not in AIR?
        • 1. Re: filesystem access
          boulder_lingie Level 1
          It's not straightforward to access a local file system in Flex because of web application security concerns. You can use HTTP service requests to get and put data (files). There is a nice file transfer sample application that comes with the ruby on rails ria sdk from adobe (look here) that shows you how to easily do this with a client/server setup. I suppose if you wanted to know when a new image was placed in a directory, you could have the server send data back to the web app (file upload complete or something) which would then cause a directory refresh.
          • 2. Re: filesystem access
            justria Level 1
            You can't access the file system directly with a Flex app in a browser. The sandbox prevents this.

            As described by boulder_lingie, workaround do exist.

            One way to get around this restriction is this:

            Create a small AIR application, which provides services to your Flex application.

            A browser-based Flex app and an AIR app can exchange message using LocalConnection: http://livedocs.adobe.com/flex/2/langref/flash/net/LocalConnection.html

            But even this approach isn't as simple as expected, because a LocalConnection can not send packages larger than 40 KBytes. Thus, you most need an AS3 class, which partitions large messages into 40 KByte chunks.

            While this requires some coding, it is by no means a complex class.

            If you managed to write a message partitioner class, why not post it to Flex Cookbook: http://www.adobe.com/cfusion/communityengine/index.cfm?event=homepage&productId=2