我有以下行动:
public function getFileAction(){
//file data is an array passed from js code
$file_data = (array)Zend_Json::decode($this->getRequest()->getParam('fileData'));
$data = array(
'id_file' => $file_data['id_file']
);
//get file data from business object
$b_file = new Application_Business_File($data);
$file = $b_file->getFile();
//to prevent view rendering
$this->getHelper('viewRenderer')->setNoRender();
$this->getResponse()->setHeader('Content-Type', 'application/pdf')
->setBody($file['fileBlob']);
}
$file['fileBlob']
实际上是一个从我的数据库中提取的blob对象。
我应该在将它放入我的回复体之前对其进行编码吗?
我想在这里尝试实现的是让这个动作为我显示一个pdf文件,就像我在这样的简单php中这样做:
filename = "file.pdf";
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file['fileBlob']);
有什么建议吗?