Fixed MIME type change issue.

This commit is contained in:
Raj Kissu Rajandran
2008-11-02 06:54:27 +00:00
parent 20a4c0251e
commit e960406e5d
6 changed files with 43 additions and 21 deletions

View File

@@ -54,6 +54,8 @@
if ($data = PMA_DBI_fetch_assoc($result))
{
$query = "SELECT count(*) FROM " . PMA_backquote($mybs_cust_content_type_tbl);
$query .= " WHERE Blob_url='" . PMA_sqlAddslashes($bsReference) . "'";
$result = PMA_DBI_query($query);
// if record exists

View File

@@ -8,8 +8,8 @@
set_time_limit(0);
$filename = isset($_REQUEST['bs_ref']) : $_REQUEST['bs_ref'] : NULL;
$c_type = isset($_REQUEST['c_type']) : $_REQUEST['c_type'] : NULL;
$filename = isset($_REQUEST['file_path']) ? $_REQUEST['file_path'] : NULL;
$c_type = isset($_REQUEST['c_type']) ? $_REQUEST['c_type'] : NULL;
if (isset($filename) && isset($c_type))
{
@@ -29,21 +29,24 @@ if (isset($filename) && isset($c_type))
$fHnd = fopen($filename, "rb");
$pos = 0;
$content = "";
while (!feof($fHnd))
if ($fHnd)
{
$content .= fread($fHnd, $f_size);
$pos = strlen($content);
$pos = 0;
$content = "";
if ($pos >= $f_size)
break;
while (!feof($fHnd))
{
$content .= fread($fHnd, $f_size);
$pos = strlen($content);
if ($pos >= $f_size)
break;
}
echo $content;
flush();
fclose($fHnd);
}
echo $content;
flush();
fclose($fHnd);
}
?>

View File

@@ -12,6 +12,11 @@
*/
$mediaType = isset($_REQUEST['media_type']) ? $_REQUEST['media_type'] : NULL;
/*
* @var string indicates whether media type is of custom type
*/
$customType = isset($_REQUEST['custom_type']) ? $_REQUEST['custom_type'] : false;
/*
* @var string contains BLOB reference
*/
@@ -29,6 +34,10 @@
// retrieve BS server variables from PMA configuration
$bs_server = $PMA_Config->get('BLOBSTREAMING_SERVER');
$bs_file_path = "http://" . $bs_server . '/' . $bsReference;
if (isset($customType) && $customType)
$bs_file_path = "bs_disp_as_mime_type.php?file_path=" . urlencode($bs_file_path) . "&c_type=" . urlencode($mediaType);
?>
<html>
<head>

View File

@@ -1250,7 +1250,7 @@ function pdfPaperSize(format, axis) {
* @param var w_width width of popup window
* @param var w_height height of popup window
*/
function popupBSMedia(url_params, bs_ref, m_type, w_width, w_height)
function popupBSMedia(url_params, bs_ref, m_type, is_cust_type, w_width, w_height)
{
// if width not specified, use default
if (w_width == undefined)
@@ -1261,7 +1261,7 @@ function popupBSMedia(url_params, bs_ref, m_type, w_width, w_height)
w_height = 480;
// open popup window (for displaying video/playing audio)
var mediaWin = window.open('bs_play_media.php?' + url_params + '&bs_reference=' + bs_ref + '&media_type=' + m_type, 'viewBSMedia', 'width=' + w_width + ', height=' + w_height + ', resizable=1, scrollbars=1, status=0');
var mediaWin = window.open('bs_play_media.php?' + url_params + '&bs_reference=' + bs_ref + '&media_type=' + m_type + '&custom_type=' + is_cust_type, 'viewBSMedia', 'width=' + w_width + ', height=' + w_height + ', resizable=1, scrollbars=1, status=0');
}
/**

View File

@@ -673,7 +673,15 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
if ($data = @PMA_DBI_fetch_assoc($result))
{
// determine content-type for BS repository file (original or custom)
$content_type = isset($data['Custom_type']) ? $data['Custom_type'] : $data['Content_type'];
$is_custom_type = false;
if (isset($data['Custom_type']))
{
$content_type = $data['Custom_type'];
$is_custom_type = true;
}
else
$content_type = $data['Content_type'];
if (!$content_type)
$content_type = NULL;
@@ -694,12 +702,12 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
break;
// audio content
case 'audio/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . $content_type . '\', 640, 120)">' . $GLOBALS['strPlayAudio']. '</a>)';
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 120)">' . $GLOBALS['strPlayAudio']. '</a>)';
break;
// video content
case 'application/x-flash-video':
case 'video/mpeg':
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . $content_type . '\', 640, 480)">' . $GLOBALS['strViewVideo'] . '</a>)';
$output .= ' (<a href="#" onclick="popupBSMedia(\'' . PMA_generate_common_url() . '\',\'' . urlencode($bs_reference) . '\', \'' . urlencode($content_type) . '\',' . ($is_custom_type ? 1 : 0) . ', 640, 480)">' . $GLOBALS['strViewVideo'] . '</a>)';
break;
// unsupported content. specify download
default:

View File

@@ -411,7 +411,7 @@ if (! PMA_isValid($_REQUEST['token']) || $_SESSION[' PMA_token '] != $_REQUEST['
/* Possible login form */
'pma_servername', 'pma_username', 'pma_password',
/* rajk - for playing blobstreamable media */
'media_type', 'bs_reference',
'media_type', 'custom_type', 'bs_reference',
/* rajk - for changing BLOB repository file MIME type */
'bs_db', 'bs_table', 'bs_ref', 'bs_new_mime_type'
);