Monday, June 2, 2008

Deleting files on a Flash Media Server

I haven't post much in a while, because I've been busy with a new project. During the evenings I've been dedicating some time to my portfolio site - I know it is long over due. Hopefully, I will be done some time in the near future. One of my featured components is a webcam. It's taking some time getting the kinks ironed out. I am fairly new to Server-Side ActionScripting and the Flash Media Server. Thanks to some folks, especially Lisa Larson-Kelly - I've been getting through the component. Tonight I figured out how to delete a file off a Flash Media Server. Here is the server-side Script:

I call the removeFile function inside my onDisconnect call. I did that so the server checks if a user published their recent webcam recording. If they didn't, the removeFile function deletes the file. Really, simple script; but most effective.



function removeFile(){
if ( !publish )
{
var file = new File("[my directory]/recorded_video.flv");
if ( file.exists )
{
file.remove();
}
}
}

No comments: