Allow use odbc to store files (record/voicemail) in database. (#1535)
* Change. Allow use odbc to store files (record/voicemail) in database. * Fix. Generate correct default config.
This commit is contained in:
committed by
FusionPBX
parent
119a007acd
commit
09f2d8fa43
@@ -325,20 +325,19 @@
|
||||
--show the storage type
|
||||
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. "\n");
|
||||
|
||||
--include the base64 function
|
||||
require "resources.functions.base64";
|
||||
--include the file io
|
||||
local file = require "resources.functions.file"
|
||||
|
||||
--base64 encode the file
|
||||
if (file_exists(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext)) then
|
||||
--get the base
|
||||
local f = io.open(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext, "rb");
|
||||
local file_content = f:read("*all");
|
||||
f:close();
|
||||
message_base64 = base64.encode(file_content);
|
||||
-- build full path to file
|
||||
local full_path = voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext
|
||||
|
||||
if file_exists(full_path) then
|
||||
--read file content as base64 string
|
||||
message_base64 = assert(file.read_base64(full_path));
|
||||
--freeswitch.consoleLog("notice", "[voicemail] ".. message_base64 .. "\n");
|
||||
|
||||
--delete the file
|
||||
os.remove(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
|
||||
os.remove(full_path);
|
||||
end
|
||||
end
|
||||
|
||||
@@ -407,13 +406,10 @@
|
||||
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
|
||||
end
|
||||
if (storage_type == "base64") then
|
||||
array = explode("://", database["system"]);
|
||||
local luasql = require "luasql.postgres";
|
||||
local env = assert (luasql.postgres());
|
||||
local db = env:connect(array[2]);
|
||||
res, serr = db:execute(sql);
|
||||
db:close();
|
||||
env:close();
|
||||
local Database = require "resources.functions.database"
|
||||
local dbh = Database.new('system', 'base64');
|
||||
dbh:query(sql);
|
||||
dbh:release();
|
||||
else
|
||||
dbh:query(sql);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user