6 Replies Latest reply on Sep 18, 2006 9:02 AM by Renaun_Erickson

    Check file exists on Flash Comm Server

    Kristian Wright Level 1
      I've created an app that lets a user record a voice sample on Flash Communication Server. I can connect to the server, record the voice sample, and play it back with no problem. But I want the user to be able to name and save multiple voice samples into a single application space.

      Is there a way to check if an flv file already exists on the server? I don't want them to be automatically written over in the event of a name clash. I've been googling and reading live docs for ages now, and it doesn't seem to be referenced anywhere!

      Either it's not possible, or it's so easy no one has asked before...

      Has anyone done this before?
        • 1. Re: Check file exists on Flash Comm Server
          Renaun_Erickson Level 1
          You'll need to use a back end language like ColdFusion to do more heavy file system manipulations. From FCS you would call a WebService or from the Flash client you would call the ColdFusion webservice that would handle the file system features as you want.
          • 2. Re: Check file exists on Flash Comm Server
            Kristian Wright Level 1
            Yeah, I thought that might be the case, and gave it a go, but it doesn't seem to be working. I've written the following cfc which I thought would take care of this:

            <cffunction name="check_file_exists" access="remote" returntype="struct" displayname="check_file_exists" hint="Checks if a file already exists on the server in the specified location">
            <cfargument name="filename" type="string" required="yes" hint="Name of file to check for">
            <cfargument name="location" type="string" required="yes" hint="Location to check for file">
            <cftry>
            <cfset return = StructNew()>
            <cfset return.status = "OK">
            <cfif FileExists("#location#\#filename#") is "Yes">
            <cfset return.details = TRUE>
            <cfelse>
            <cfset return.details = FALSE>
            </cfif>
            <cfreturn return>
            <cfcatch>
            <cfset return = StructNew()>
            <cfset return.status = "BAD">
            <cfreturn return>
            </cfcatch>
            </cftry>
            </cffunction>

            But no matter if the file exists or not, it always returns TRUE, even when I can physically see that the file is not there. For this reason I assumed that the cfc can't access the Flash Comm server in this way, as it doesn't cause an error, but returns the wrong information.

            That's why I thought there must be another way...
            • 3. Re: Check file exists on Flash Comm Server
              Kristian Wright Level 1
              Forgot to mention that the location and file are specified as:

              location: "FlashcomserverIP\application\directory"
              file: "filename.flv"
              • 4. Re: Check file exists on Flash Comm Server
                Renaun_Erickson Level 1
                Well there might be permission errors if the user running ColdFusion does not have access to the folder where the FCS files are being created. This is more of a problem on linux.

                All I can say is start back with hard coded Paths in the cfc and test it outside the Flex application to try and get some kind of error message from ColdFusion. I assume you checked all the /opt/coldfusionmx7/logs/.
                • 5. Re: Check file exists on Flash Comm Server
                  Kristian Wright Level 1
                  I've realised that the CFC will never work, as my Flash Comm Server and ColdFusion server are two different machines. So I guess this question will probably be better posted on the ColdFusion forum (which I'll do, but worth a go here anyway...) - is it possible to check for the existance of a file on a different server from the one the CFC is on?
                  • 6. Re: Check file exists on Flash Comm Server
                    Renaun_Erickson Level 1
                    You'll have to have something on the server with FMS that provides the information through an HTTP/WebService call.

                    About the only other option is to try and Connect to the FMS with the filename portion with a NetStream. If you load it and find that it has a length greater than zero you can be fairly sure there is a file present.