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