If it helps the source for the built in file mover is here:
import java.io.*;
import java.util.*;
import com.wowza.util.*;
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;
import com.wowza.wms.stream.*;
import com.wowza.wms.vhost.*;
public class ModuleMediaWriterFileMover extends ModuleBase implements IMediaWriterActionNotify
{
String fileMoverDestinationPath = null;
String fileMoverFileExtension = null;
boolean fileMoverVersionFile = true;
boolean fileMoverDeleteOriginal = false;
public void onAppStart(IApplicationInstance appInstance)
{
appInstance.addMediaWriterListener(this);
getLogger().info("ModuleMediaWriterFileMover.onAppStart: "+appInstance.getContextStr());
WMSProperties props = appInstance.getProperties();
fileMoverDestinationPath = props.getPropertyStr("fileMoverDestinationPath", fileMoverDestinationPath);
fileMoverFileExtension = props.getPropertyStr("fileMoverFileExtension", fileMoverFileExtension);
fileMoverVersionFile = props.getPropertyBoolean("fileMoverVersionFile", fileMoverVersionFile);
fileMoverDeleteOriginal = props.getPropertyBoolean("fileMoverDeleteOriginal", fileMoverDeleteOriginal);
}
private String getExtension(IMediaStream stream, String ext)
{
if (ext == null)
{
String mediaReaderType = stream.getExt().toLowerCase();
MediaReaderItem mediaReaderItem = stream.getStreams().getVHost().getMediaReaders().getMediaReaderDef(mediaReaderType);
return mediaReaderItem.getFileExtension();
}
return ext;
}
public void onWriteComplete(IMediaStream stream, File file)
{
if (fileMoverDestinationPath != null)
{
String streamName = FileUtils.toValidFilename(stream.getName());
String streamExt = getExtension(stream, fileMoverFileExtension);
Map<String, String> envMap = new HashMap<String, String>();
IApplicationInstance appInstance = stream.getStreams().getAppInstance();
IVHost vhost = appInstance.getVHost();
envMap.put("com.wowza.wms.context.VHost", vhost.getName());
envMap.put("com.wowza.wms.context.VHostConfigHome", vhost.getHomePath());
envMap.put("com.wowza.wms.context.Application", appInstance.getApplication().getName());
envMap.put("com.wowza.wms.context.ApplicationInstance", appInstance.getName());
envMap.put("com.wowza.wms.context.StreamName", streamName);
String destinationPath = SystemUtils.expandEnvironmentVariables(fileMoverDestinationPath, envMap);
if (fileMoverDestinationPath.indexOf("com.wowza.wms.context.StreamName") < 0)
destinationPath += "/"+streamName+"."+streamExt;
File dstFile = new File(destinationPath);
getLogger().info("ModuleMediaWriterFileMover.onWriteComplete: from: "+file+" to:"+dstFile);
try
{
dstFile.getParentFile().mkdirs();
}
catch(Exception e)
{
getLogger().warn("ModuleMediaWriterFileMover.onWriteComplete[mkdir]: ["+dstFile+"]: "+e.toString());
}
try
{
if (dstFile.exists())
{
if (fileMoverVersionFile)
FileUtils.versionFile(dstFile);
else
dstFile.delete();
}
}
catch(Exception e)
{
getLogger().warn("ModuleMediaWriterFileMover.onWriteComplete[version]: ["+dstFile+"]: "+e.toString());
}
try
{
FileUtils.copyFile2(file, dstFile);
}
catch(Exception e)
{
getLogger().warn("ModuleMediaWriterFileMover.onWriteComplete[version]: ["+dstFile+"]: "+e.toString());
}
try
{
if (fileMoverDeleteOriginal && dstFile.exists())
{
file.delete();
}
}
catch(Exception e)
{
getLogger().warn("ModuleMediaWriterFileMover.onWriteComplete[delOrig]: ["+dstFile+"]: "+e.toString());
}
}
}
public void onFLVAddMetadata(IMediaStream stream, Map<String, Object> extraMetadata)
{
}
}
Charlie