public function actionGetImage($id)
{
if (!($file = \MediaData::model()->findByPk($id))) {
throw new CHttpException(404, 'File not found');
}
$filepath = $file->getPath();
if (!file_exists($file->getPath())) {
throw new CException('File not found on filesystem: ' . $file->getPath());
}
//var_dump($file);
//die;
header('Content-Type: ' . \MediaType::model()->findByPk($file->media_type_id)->type_mime);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Content-Length: ' . $file->original_file_size);
ob_clean();
flush();
readfile($filepath);
}