From 3e5946a58f5f322fa640b9fdb289a4c65973fa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guy=20Couronn=C3=A9?= Date: Wed, 2 Apr 2014 10:08:19 -0400 Subject: [PATCH] Add support for createDocumentFromSource. --- atom/cmis/cmis_service.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/atom/cmis/cmis_service.php b/atom/cmis/cmis_service.php index e52b384..47cbaac 100644 --- a/atom/cmis/cmis_service.php +++ b/atom/cmis/cmis_service.php @@ -999,8 +999,16 @@ function createDocument($folderId, $fileName, $properties = array (), $content = return $this->postObject($folderId, $fileName, "cmis:document", $properties, $content, $content_type, $options); } - function createDocumentFromSource() { //Yes? - throw new CmisNotSupportedException("createDocumentFromSource is not supported by the AtomPub binding!"); + function createDocumentFromSource($folderId, $fileName, $fileNameFrom, $properties = array(), $options = array()) { //Yes? + //Get content_type + $finfo = finfo_open(FILEINFO_MIME); + $content_type = finfo_file($finfo, $fileNameFrom); + finfo_close($finfo); + + //Get content + $content = file_get_contents($fileNameFrom); + + return $this->createDocument($folderId, $fileName, $properties, $content, $content_type, $options); } function createFolder($folderId, $folderName, $properties = array (), $options = array ()) { // Yes @@ -1280,4 +1288,4 @@ function getACL() { function applyACL() { throw new CmisNotImplementedException("applyACL"); } -} \ No newline at end of file +}