For my client I have to use blob storage for some various files.
So I have created a independent bundle with a Blob class extends DoctrineDBALTypesType.
and with a boot function in the bundle class.
That works pretty fine I can write in the database Blob datas.
But I can't download any document after :/
I have got:
public function downloadAction($id) {
$em = $this->getDoctrine()->getManager();
/* @var $entity Document */
$entity = $em->getRepository('Lille3SapBundle:Document')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Document entity.');
}
$file = $entity->getFichier();
$response = new SymfonyComponentHttpFoundationResponse($file, 200, array(
'Content-Type' => 'application/octet-stream',
'Content-Length' => sizeof($file),
'Content-Disposition' => 'attachment; filename="'.$entity->getNomDocument().'"',
));
return $response;
}
and I have got an Exception:
The Response content must be a string or object implementing __toString(), "resource" given.
in fact, the $file values is not the expected BLOB but something like Resource id #123
-> I have check blob data fields values, and they are ok in the database
So how can I force in the controller to have the blob row and not a Resource id #111
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…