/**
  * Function Used to get Data from Nuxeo, such as a blob. MUST BE PERSONALISED. (Or just move the
  * headers)
  *
  * @param string $path path of the file
  * @throws NuxeoClientException
  * @deprecated Use \Nuxeo\Client\Api\Objects\Blob::fromFilename
  */
 function getFileContent($path)
 {
     $eurl = explode('/', $path);
     $client = new NuxeoPhpAutomationClient('http://localhost:8080/nuxeo/site/automation');
     try {
         $session = $client->getSession('Administrator', 'Administrator');
     } catch (\Nuxeo\Client\Internals\Spi\NuxeoClientException $ex) {
         throw new NuxeoClientException($ex->getMessage());
     }
     $answer = $session->newRequest('Chain.getDocContent')->set('context', 'path' . $path)->sendRequest();
     if (null === $answer or false === $answer) {
         throw new NuxeoClientException('$answer is not set');
     } else {
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header('Content-Disposition: attachment; filename=' . end($eurl) . '.pdf');
         readfile('tempstream');
     }
 }
 public function testAttachBlob()
 {
     $client = new NuxeoPhpAutomationClient($this->server->getUrl());
     $session = $client->getSession(self::LOGIN, self::PASSWORD);
     $this->server->enqueue(array(new Response(200)));
     $session->newRequest('Blob.Attach')->set('params', 'document', array('entity-type' => 'string', 'value' => self::MYFILE_DOCPATH))->loadBlob($this->getResource(self::NEWFILE_PATH), self::NEWFILE_TYPE)->sendRequest();
     $requests = $this->server->getReceivedRequests(true);
     $this->assertCount(1, $requests);
     /** @var EntityEnclosingRequest $request */
     $request = $requests[0];
     $this->assertArrayHasKey('content-type', $request->getHeaders());
     $this->assertStringMatchesFormat('multipart/related;boundary=%s', $request->getHeader('content-type')->__toString());
     $this->assertArrayHasKey('x-nxvoidoperation', $request->getHeaders());
     $this->assertEquals('true', $request->getHeader('x-nxvoidoperation')->__toString());
     //    $this->assertArrayHasKey('accept', $request->getHeaders());
     //    $this->assertEquals('application/json+nxentity, */*', $request->getHeader('accept')->__toString());
     $this->assertContains($this->readPartFromFile('setblob-part1.txt'), $request->getBody()->__toString());
     $this->assertContains($this->readPartFromFile('setblob-part2.txt'), $request->getBody()->__toString());
 }