I'm building an application that inserts documents into MarkLogic server using the MLPHP library. The problem is when I insert a binary document, for example a PDF. The mime type will not be set properly, therefore the file cannot be opened as it should.
This is the code I use to insert a document:
// initialize REST client$client = new MLPHP\RESTClient('127.0.0.1', 8010, 'v1', '', 'rest-writer-user', 'writer-pw');// create new document and load content$doc = new MLPHP\Document($client);$doc->setContentType("application/pdf"); $doc->setContentFile("demo.pdf"); $doc->write('pdf_demo');
This is a dump of the $doc object after submitting to the server:
And here we have the inserted document in the search results:
But as expected, the browser cannot handle the file due to the wrong mimetype:
Anyone has got a clue what's going wrong here?