#!/usr/bin/ruby
# encoding: UTF-8
require "trollop"
require 'aws-sdk-s3'
require File.expand_path('../../../lib/recordandplayback', __FILE__)
opts = Trollop::options do
opt :meeting_id, "Meeting id to archive", :type => String
opt :format, "Playback format name", :type => String
end
meeting_id = opts[:meeting_id]
logger = Logger.new("/var/log/bigbluebutton/post_publish.log", 'weekly' )
#logger = Logger.new("/mnt/post_publish.log", 'weekly' )
logger.level = Logger::INFO
BigBlueButton.logger = logger
published_files = "/var/bigbluebutton/published/presentation/#{meeting_id}"
#published_files = "/mnt/mam-test"
meeting_metadata = BigBlueButton::Events.get_meeting_metadata("/var/bigbluebutton/recording/raw/#{meeting_id}/events.xml")
#meeting_metadata = BigBlueButton::Events.get_meeting_metadata("/mnt/mam-test/events.xml")
def object_uploaded?(s3_client, bucket_name, file, object_key)
if File.directory?(file)
response = s3_client.put_object({ bucket: bucket_name, key: object_key })
else
data = File.open(file)
response = s3_client.put_object({ bucket: bucket_name, key: object_key, body: data })
data.close
end
response.etag ? true : false
rescue StandardError => e
puts "Error uploading object: #{e.message}"
false
end
bucket_name = 'manjuanu-bucket'
region = 'ap-south-1'
s3_client = Aws::S3::Client.new(
region: region,
credentials: Aws::Credentials.new('AKIAUOL6MOWTF67HT5VF', 'gUbdk1rVwul1veEh7mM4yxDHShvO3cRl793vxvEQ')
)
BigBlueButton.logger.info("S3 Uploader Running for meeting #{meeting_id}")
Dir.glob("#{published_files}/**/*") do |file|
bucket_file = file.gsub("/var/bigbluebutton/published/presentation/", "")
if object_uploaded?(s3_client, bucket_name, file, bucket_file)
BigBlueButton.logger.info("#{bucket_file} uploaded successfully!")
else
BigBlueButton.logger.info("#{bucket_file} upload failed!")
end
end
BigBlueButton.logger.info("S3 Upload completed for meeting #{meeting_id}")
exit 0
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}