Improve error handling when a recording download fails (#6592)
This commit is contained in:
@@ -780,11 +780,16 @@
|
|||||||
//prepare and stream the file
|
//prepare and stream the file
|
||||||
if (file_exists($path.'/msg_'.$this->voicemail_message_uuid.'.wav')) {
|
if (file_exists($path.'/msg_'.$this->voicemail_message_uuid.'.wav')) {
|
||||||
$file_path = $path.'/msg_'.$this->voicemail_message_uuid.'.wav';
|
$file_path = $path.'/msg_'.$this->voicemail_message_uuid.'.wav';
|
||||||
}
|
} else if (file_exists($path.'/msg_'.$this->voicemail_message_uuid.'.mp3')) {
|
||||||
if (file_exists($path.'/msg_'.$this->voicemail_message_uuid.'.mp3')) {
|
|
||||||
$file_path = $path.'/msg_'.$this->voicemail_message_uuid.'.mp3';
|
$file_path = $path.'/msg_'.$this->voicemail_message_uuid.'.mp3';
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if ($file_path != '') {
|
|
||||||
|
if ($file_path == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//content-range
|
//content-range
|
||||||
if (isset($_SERVER['HTTP_RANGE']) && $this->type != 'bin') {
|
if (isset($_SERVER['HTTP_RANGE']) && $this->type != 'bin') {
|
||||||
$this->range_download($file_path);
|
$this->range_download($file_path);
|
||||||
@@ -802,8 +807,7 @@
|
|||||||
case "mp3" : header('Content-Disposition: attachment; filename="msg_'.$this->voicemail_message_uuid.'.mp3"'); break;
|
case "mp3" : header('Content-Disposition: attachment; filename="msg_'.$this->voicemail_message_uuid.'.mp3"'); break;
|
||||||
case "ogg" : header('Content-Disposition: attachment; filename="msg_'.$this->voicemail_message_uuid.'.ogg"'); break;
|
case "ogg" : header('Content-Disposition: attachment; filename="msg_'.$this->voicemail_message_uuid.'.ogg"'); break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$file_ext = pathinfo($file_path, PATHINFO_EXTENSION);
|
$file_ext = pathinfo($file_path, PATHINFO_EXTENSION);
|
||||||
switch ($file_ext) {
|
switch ($file_ext) {
|
||||||
case "wav" : header("Content-Type: audio/x-wav"); break;
|
case "wav" : header("Content-Type: audio/x-wav"); break;
|
||||||
@@ -818,7 +822,6 @@
|
|||||||
}
|
}
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
fpassthru($fd);
|
fpassthru($fd);
|
||||||
}
|
|
||||||
|
|
||||||
//if base64, remove temp file
|
//if base64, remove temp file
|
||||||
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
|
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
|
||||||
|
|||||||
@@ -45,7 +45,9 @@
|
|||||||
$voicemail->voicemail_id = $_REQUEST['id'];
|
$voicemail->voicemail_id = $_REQUEST['id'];
|
||||||
$voicemail->voicemail_uuid = $_REQUEST['voicemail_uuid'];
|
$voicemail->voicemail_uuid = $_REQUEST['voicemail_uuid'];
|
||||||
$voicemail->voicemail_message_uuid = $_REQUEST['uuid'];
|
$voicemail->voicemail_message_uuid = $_REQUEST['uuid'];
|
||||||
$result = $voicemail->message_download();
|
if(!$voicemail->message_download()) {
|
||||||
|
echo "unable to download voicemail";
|
||||||
|
}
|
||||||
unset($voicemail);
|
unset($voicemail);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1286,10 +1286,17 @@ if (!class_exists('xml_cdr')) {
|
|||||||
* download the recordings
|
* download the recordings
|
||||||
*/
|
*/
|
||||||
public function download($uuid) {
|
public function download($uuid) {
|
||||||
if (permission_exists('xml_cdr_view')) {
|
if (!permission_exists('xml_cdr_view')) {
|
||||||
|
echo "permission denied";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//get call recording from database
|
//get call recording from database
|
||||||
if (is_uuid($uuid)) {
|
if (!is_uuid($uuid)) {
|
||||||
|
echo "invalid uuid";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sql = "select record_name, record_path from v_xml_cdr ";
|
$sql = "select record_name, record_path from v_xml_cdr ";
|
||||||
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
|
$sql .= "where xml_cdr_uuid = :xml_cdr_uuid ";
|
||||||
//$sql .= "and domain_uuid = '".$domain_uuid."' \n";
|
//$sql .= "and domain_uuid = '".$domain_uuid."' \n";
|
||||||
@@ -1300,19 +1307,26 @@ if (!class_exists('xml_cdr')) {
|
|||||||
if (is_array($row)) {
|
if (is_array($row)) {
|
||||||
$record_name = $row['record_name'];
|
$record_name = $row['record_name'];
|
||||||
$record_path = $row['record_path'];
|
$record_path = $row['record_path'];
|
||||||
|
} else {
|
||||||
|
echo "recording not found";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
unset ($sql, $parameters, $row);
|
unset ($sql, $parameters, $row);
|
||||||
}
|
|
||||||
|
|
||||||
//build full path
|
//build full path
|
||||||
$record_file = $record_path.'/'.$record_name;
|
$record_file = $record_path.'/'.$record_name;
|
||||||
|
|
||||||
//download the file
|
//download the file
|
||||||
if (file_exists($record_file)) {
|
if (!file_exists($record_file)) {
|
||||||
|
echo "recording not found";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//content-range
|
//content-range
|
||||||
if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") {
|
if (isset($_SERVER['HTTP_RANGE']) && $_GET['t'] != "bin") {
|
||||||
$this->range_download($record_file);
|
$this->range_download($record_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_clean();
|
ob_clean();
|
||||||
$fd = fopen($record_file, "rb");
|
$fd = fopen($record_file, "rb");
|
||||||
if ($_GET['t'] == "bin") {
|
if ($_GET['t'] == "bin") {
|
||||||
@@ -1320,8 +1334,7 @@ if (!class_exists('xml_cdr')) {
|
|||||||
header("Content-Type: application/octet-stream");
|
header("Content-Type: application/octet-stream");
|
||||||
header("Content-Type: application/download");
|
header("Content-Type: application/download");
|
||||||
header("Content-Description: File Transfer");
|
header("Content-Description: File Transfer");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$file_ext = pathinfo($record_name, PATHINFO_EXTENSION);
|
$file_ext = pathinfo($record_name, PATHINFO_EXTENSION);
|
||||||
switch ($file_ext) {
|
switch ($file_ext) {
|
||||||
case "wav" : header("Content-Type: audio/x-wav"); break;
|
case "wav" : header("Content-Type: audio/x-wav"); break;
|
||||||
@@ -1338,8 +1351,7 @@ if (!class_exists('xml_cdr')) {
|
|||||||
}
|
}
|
||||||
ob_clean();
|
ob_clean();
|
||||||
fpassthru($fd);
|
fpassthru($fd);
|
||||||
}
|
|
||||||
}
|
|
||||||
} //end download method
|
} //end download method
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user