Fixed bug where MIME type could not be changed for BLOB repository references. Added bs_disp_as_mime_type.php to represent files under different MIME types until a better solution can be found

This commit is contained in:
Raj Kissu Rajandran
2008-10-31 19:20:32 +00:00
parent 32d250a9f8
commit 20a4c0251e
3 changed files with 53 additions and 5 deletions

49
bs_disp_as_mime_type.php Normal file
View File

@@ -0,0 +1,49 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* @author Raj Kissu Rajandran
* @version 1.0
* @package BLOBStreaming
*/
set_time_limit(0);
$filename = isset($_REQUEST['bs_ref']) : $_REQUEST['bs_ref'] : NULL;
$c_type = isset($_REQUEST['c_type']) : $_REQUEST['c_type'] : NULL;
if (isset($filename) && isset($c_type))
{
$hdrs = get_headers($filename, 1);
if (is_array($hdrs))
$f_size = $hdrs['Content-Length'];
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: $c_type");
header('Content-length: ' . $f_size);
header("Content-disposition: attachment; filename=" . basename($filename));
$fHnd = fopen($filename, "rb");
$pos = 0;
$content = "";
while (!feof($fHnd))
{
$content .= fread($fHnd, $f_size);
$pos = strlen($content);
if ($pos >= $f_size)
break;
}
echo $content;
flush();
fclose($fHnd);
}
?>

View File

@@ -1297,10 +1297,10 @@ function requestMIMETypeChange(db, table, reference, current_mime_type)
function changeMIMEType(db, table, reference, mime_type) function changeMIMEType(db, table, reference, mime_type)
{ {
// specify url and parameters for mootools AJAx request // specify url and parameters for mootools AJAx request
var url = 'bs_change_mime_type.php'; var mime_chg_url = 'bs_change_mime_type.php';
var params = { bs_db: db, bs_table: table, bs_reference: reference, bs_new_mime_type: mime_type }; var params = { bs_db: db, bs_table: table, bs_reference: reference, bs_new_mime_type: mime_type };
// create AJAX object with above options and execute request // create AJAX object with above options and execute request
var chgRequest = new Ajax('bs_change_mime_type.php', { method: 'post', data: params, evalScripts: true }); var chgRequest = new Request({ method: 'post', url: mime_chg_url, data: params, evalScripts: true });
chgRequest.request(); chgRequest.send();
} }

View File

@@ -181,7 +181,6 @@ EOD;
Last_access_time TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)', Last_access_time TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
Content_type CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls', Content_type CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
Blob_data LONGBLOB COMMENT 'The data of this BLOB' Blob_data LONGBLOB COMMENT 'The data of this BLOB'
// load PMA configuration
) ENGINE=PBMS; ) ENGINE=PBMS;
EOD; EOD;
@@ -700,7 +699,7 @@ function PMA_BS_CreateReferenceLink($bs_reference, $db_name)
// video content // video content
case 'application/x-flash-video': case 'application/x-flash-video':
case 'video/mpeg': 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) . '\', \'' . $content_type . '\', 640, 480)">' . $GLOBALS['strViewVideo'] . '</a>)';
break; break;
// unsupported content. specify download // unsupported content. specify download
default: default: