How to store and retrieve a PDF file in PHPCR?

154 Views Asked by At

I am using Apache Jackrabbit server as WebDAV server as our application's file storage backend. The application is developed using PHP. I want to store a PDF file and retrieve it back from jackrabbit server using PHP content repository.

Can anyone help me on this?

Sample code used is given below, For storing:

$session = $this->getjackrabbitSession();
$node = $session->getNode('/project/files/test.pdf');
$contents = file_get_contents($fileURL);
$node->setProperty("nt:file", $contents);
$node->setProperty("mimeType", 'application/pdf');
$node->setProperty("fileName", 'test.pdf');
$session->save();

For retrieving:

$session = $this->getjackrabbitSession();
$node = $session->getNode('/project/files/test.pdf');
$contents = $node->getContent();
$mimeType = $node->getPropertyValue('mimeType');
$fileName = $node->getPropertyValue('fileName');
0

There are 0 best solutions below