Skip to main content
Participant
April 26, 2007
Question

File exists problem

  • April 26, 2007
  • 3 replies
  • 313 views
I have some trouble with overwriteing previous streams i recorded. My app is simple i want to record a stream and then let the user view it. He can then record the stream again and view the new recording. My problem is that when a recording is done i copy it to another location (using virtual directory mapping) only when i check for the just created recording by doing the following:

var tmp = new File("streams/instancename/recording");
if ( tmp.exists){
//copy the file
}
else{
trace("recording not found";
}

it traces that the recording is not found. Has this something to do with the fact that the recording thas was written by FMS needs more time before the file system realizes it is there? Besides that i have the problem that when i overwrite an flv file an play it, the old recording is shown and not the new one. Has this something to do with caching because the old recording does not exist any more as a file? I tried several things but i am nog getting any further so any help would be appreciated...

    This topic is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    crash666Author
    Participant
    April 27, 2007
    b.t.w. i also tried the other property from the file class, namely isFile but that does not work either. The difference between the two is not really clear to me but just to be sure
    April 27, 2007
    The file class is looking for a file name, not a stream name. When you use this:

    var tmp = new File("streams/instancename/recording");

    the file class is looking for a directory named "recording", where you want a file named recording.flv . Try this:

    var tmp = new File("streams/instancename/recording.flv");
    crash666Author
    Participant
    April 27, 2007
    sorry i was not clear on that, but the string i used actually included the extension so recording actually is recording.flv. Here is the actual code. It is fired immediately after the recording is unpublished and the netstream is closed so that is why i was thinking it has something to do with the filesystem not realizing its there yet.

    Client.prototype.moveCompletedFile = function() {

    var completedFLV = new File("/streams/" + instancename + "/" + clipname); //this includes the .flv extension
    var thedate = new Date();

    //check if file was correctly created
    if(completedFLV.exists){ //HERE IT DOES NOT FIND THE RECORDED STREAM???

    //check if completed dir already exists and if not create it

    //check if video file already exists if so, delete it
    var tmpFLV = new File("/completed/"+clipname);
    if (tmpFLV.exists){
    if(!tmpFLV.remove()){
    trace("file removal of existing completed file failed, client : " + clientname +" at : " + thedate.toString());
    returnvalue=false;
    }
    }

    //now move recorded file and remove file from standard location
    if(completedFLV.copyTo("/completed/"+clipname)){
    if(!completedFLV.remove()){
    trace("file removal failed, client : " + clientname +" at : " + thedate.toString());
    }
    }
    else{
    trace("file copying failed, client : " + clientname +" at : " + thedate.toString());
    }

    }
    else{
    trace("completed file does not exist, client : " + clipname+ " : client : " + clientname +" at : " + thedate.toString());
    }