Hello Salvatore, yes I developed a module based on ModuleMediaWriterFileMover.
I found the solution, upgrade to the last version of Wowza
My Code is like (I hove somebody we will reuse it!)
Application XML add
bucketName
MY_BUCKET_NAME
region
MY_REGION (for example eu-west-1)
s3_folder
MY_S3_FOLDER
access_key_id
MY_S3_ACCESS_KEY
secret_access_key
MY_S3_SECRET
New Module
public class UploadToS3 extends ModuleBase {
public void onAppStart(IApplicationInstance appInstance) {
_appInstance = appInstance;
WMSProperties props = appInstance.getProperties();
String access_key_id = props.getPropertyStr(“access_key_id”, null);
String bucketName = props.getPropertyStr(“bucketName”, null);
String secret_access_key = props.getPropertyStr(“secret_access_key”, null);
getLogger().info("Videochat on app es bucketName "+bucketName);
if (access_key_id!=null) {
String region = props.getPropertyStr(“region”, null);
String s3_folder = props.getPropertyStr(“s3_folder”, null);
String fileMoverFileExtension = props.getPropertyStr(“fileMoverFileExtension”, null);
boolean fileMoverDeleteOriginal = props.getPropertyBoolean(“fileMoverDeleteOriginal”, false);
appInstance.addMediaWriterListener(new WriteListener( bucketName, region, s3_folder, access_key_id, secret_access_key,
fileMoverFileExtension,
fileMoverDeleteOriginal));
}
}
class WriteListener implements IMediaWriterActionNotify
{
private String bucketName = null;
private String access_key_id = null;
private String secret_access_key = null;
private String s3_folder = null;
private String region = null;
private String fileMoverFileExtension = null;
private boolean fileMoverDeleteOriginal = false;
public WriteListener(String bucketName, String region, String s3_folder, String access_key_id, String secret_access_key, String fileMoverFileExtension,
boolean fileMoverDeleteOriginal) {
this.bucketName = bucketName;
this.region = region;
this.s3_folder = s3_folder;
this.access_key_id = access_key_id;
this.secret_access_key = secret_access_key;
this.fileMoverFileExtension = fileMoverFileExtension;
this.fileMoverDeleteOriginal = fileMoverDeleteOriginal;
}
/**
- Onwrite complete move the file
*/
public void onWriteComplete(IMediaStream stream, File file)
{
try {
//using S3
if (bucketName!=null && access_key_id != null && secret_access_key!= null) {
Thread t = new Thread(new MoverThreadS3(bucketName, region, s3_folder, access_key_id, secret_access_key,
fileMoverFileExtension,
file, stream));
getLogger().warn(" STARTED!!!");
t.start();
}
} catch (Throwable e){
getLogger().error("onWriteComplete - ERROR - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: : "+e.toString(), e);
}
}
public void onFLVAddMetadata(IMediaStream stream, Map<String, Object> extraMetadata)
{
}
}
private static class MoverThreadS3
implements Runnable {
private String bucketName = null;
private String region = null;
private String s3_folder = null;
private String access_key_id = null;
private String secret_access_key = null;
private String fileMoverFileExtension = null;
private File file;
private IMediaStream stream;
public MoverThreadS3(String bucketName, String region, String s3_folder, String access_key_id, String secret_access_key,
String fileMoverFileExtension,
File file, IMediaStream stream) {
this.bucketName = bucketName ;
this.region = region;
this.s3_folder = s3_folder;
this.access_key_id = access_key_id ;
this.secret_access_key = secret_access_key;
this.fileMoverFileExtension = fileMoverFileExtension;
this.file = file;
this.stream = stream;
}
public void run() {
if (bucketName !=null && access_key_id != null && secret_access_key !=null)
{
try {
BasicAWSCredentials awsCreds = new BasicAWSCredentials(access_key_id, secret_access_key);
AmazonS3 s3 = null;
String streamExt = getExtension(stream, fileMoverFileExtension);
String key = stream.getName();
if (!key.endsWith("."+streamExt)) {
key += “.”+streamExt;
}
if (s3_folder!=null && s3_folder.length()>0){
key = s3_folder + “/” +key;
}
s3 = new AmazonS3Client(awsCreds);
if (region!=null){
Region customRegion = Region.getRegion(Regions.fromName(region));
//s3.setEndpoint(customRegion.getServiceEndpoint(ServiceAbbreviations.S3));
s3.setRegion(customRegion);
}
s3.putObject(new PutObjectRequest(bucketName, key,
file));
boolean deleted = file.delete();
if (deleted) {
getLogger().info(“Thread Videochat - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: S3 uploaded “+key+” SUCESSFULLY and deleted!!!”);
} else {
getLogger().warn("Thread Videochat - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: S3 uploaded “+key+” SUCESSFULLY and but can’t deleted it!!! "+file.getAbsolutePath());
}
}
catch(Throwable e)
{
getLogger().error("Thread Videochat - ERROR - ModuleMediaWriterFileMoverS3.onWriteComplete[version]: : "+e.toString(), e);
}
} else {
getLogger().warn("Thread Videochat - WARN - ModuleMediaWriterFileMoverS3.onWriteComplete missing some required parameter : bucketName is not null: “+(bucketName !=null)+”. access_key_id is not null: " + (access_key_id != null) + ". secret_access_key is not null: "+ (secret_access_key !=null));
}
}
private static 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;
}
}
}
You will need 3 jars: the latest version of AWS Java (http://aws.amazon.com/sdk-for-java/), httpclient-4.3.6.jar and httpcore-4.3.3.jar
Best regards