Here is the code snippet that i implemented version Q2A 1.6.3
Created a new download.php under qa-include
$userid=qa_get_logged_in_userid();
error_log("Logged in User " . $userid);
if( $userid){
$file = "dl/".$requestparts[1];
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
}
} else {
$qa_content=qa_content_prepare();
$qa_content['error']=qa_insert_login_links(qa_lang_html('question/download_must_login'), qa_request(), isset($followpostid) ? array('follow' => $followpostid) : null);
return $qa_content;
}
In the qa-page.php routing add a mapping for download to above file