Commit 43054fce authored by alexm98's avatar alexm98

Added setMimeHeader, works for PDF,PNG and GIFs. Need to check other mimes.

parent 13e080c6
......@@ -31,13 +31,22 @@ class FileController extends Controller
foreach($mimes as $key=>$value){
if(strpos($hex,$value) !== FALSE){
echo $key;
return $key;
}
}
}
public function setMimeHeader(){
// set correct header for showing the data type
public function setMimeHeader($mimetype){
$headers = [
'PDF' => 'application/pdf',
'PNG' => 'image/png',
'GIF' => 'image/gif',
];
// error supressing @headers[$mimetype] because it might fatal err to undefined index
if(@$headers[$mimetype] != NULL){
header('Content-Type:'.$headers[$mimetype]);
}
}
/**
......@@ -79,8 +88,10 @@ class FileController extends Controller
*/
public function show($hash)
{
// echo $this->ipfs->cat($hash);
self::getMime($hash);
$mime = self::getMime($hash);
self::setMimeHeader($mime);
echo $this->ipfs->cat($hash);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment