5 Replies Latest reply on Jul 27, 2009 9:10 AM by Joe ... Ward

    Drag object (document reference) from AIR to desktop

    Jan Babicky Level 1

      Hello,

       

      I was searching for oposite direction of the AIR - Desktop sync. If I have a document reference available in the AIR app, how do I store it on the destination (local filesystem) by taking advance of the drag-drop feature. I have a image that visualy represents the file in the app (returned from webservice) and I want user to be able to drag that image to local filesystem and store a file this way.

      Any suggestions how this can be done?

      Thanks

       

      Jan

        • 1. Re: Drag object (document reference) from AIR to desktop
          Joe ... Ward Level 4

          You can download the file from the webservice to a temporary directory. When the drag starts, you add the reference to the selected files in the temp directory to the drag-and-drop clipboard. The OS takes care of moving/copying the files when the user drops them outside your app.

           

          Note that it currently isn't possible to have the user drag a visual reference of a file to the desktop and THEN download the file from the web service. You might think that you could use a clipboard data handler for this, but, unfortunately, the OS calls the data handler function as soon as the drag gesture leaves the AIR app. This results in an inconvenient pause as the file is downloaded.

          1 person found this helpful
          • 2. Re: Drag object (document reference) from AIR to desktop
            Jan Babicky Level 1

            Hi Joe,

             

            I can not use the drag to the desktop feature even though that the actual webservice returns URL from where the file can be downloaded and not the actual binary file itself? Will there still be that inconvenient pause you are talking about?

            Thanks

             

            J

            • 3. Re: Drag object (document reference) from AIR to desktop
              Joe ... Ward Level 4

              If you only have a URL, then you can't drag it out of the AIR application and then subsequently download the file to the drop location. There's no way to know where the file was dropped (the OS doesn't provide this sort of feedback).

               

              The inconvenient pause occurs when you use a data handler function to download the file after the drop. Unfortunately the OS (at least Windows and Mac) call the function as soon as the drag gesture leaves your application. The pause occurs because the file is being downloaded by the handler function.

              1 person found this helpful
              • 4. Re: Drag object (document reference) from AIR to desktop
                Jan Babicky Level 1

                Hi Joe,

                 

                at the end, I am doing what you suggested in previous post. The AIR application does PDF conversion using the LiveCycle capabilities.

                What I do is drag the file to the app, upload it using the build in method for fileupload and get the reference once uploaded. Convert the document and once converted, I download the file from URL to the applicationStorageDirectory and than enable the drag out feature from the app to the filesystem.

                 

                Since this is my first AIR app, I would like to check if this scenario is ok and if I have to delete files either on the server or in the applicationStorageDirectory once the file is draged out from the app. Why I am asking this is that I do not want to leave garbage either on the server or the users computer.

                 

                Thanks again,

                 

                J.

                • 5. Re: Drag object (document reference) from AIR to desktop
                  Joe ... Ward Level 4

                  If you only allow the move action on the drag & drop, then the files will be removed from the storage directory by the OS. If you let the user do a copy action, then unneeded files could be left behind. I don't know much about LiveCycle, but I wouldn't think the files are deleted from the server just because you downloaded them, unless you set it up that way (somehow).