You are here

static function CMISService::getContentEntry in CMIS API 7

Same name and namespace in other branches
  1. 6.4 cmis_common/lib/cmis_repository_wrapper.php \CMISService::getContentEntry()
  2. 6.3 cmis_common/lib/cmis_repository_wrapper.php \CMISService::getContentEntry()
1 call to CMISService::getContentEntry()
CMISService::postObject in cmis_common/lib/cmis_repository_wrapper.php

File

cmis_common/lib/cmis_repository_wrapper.php, line 726

Class

CMISService

Code

static function getContentEntry($content, $content_type = "application/octet-stream") {
  static $contentTemplate;
  if (!isset($contentTemplate)) {
    $contentTemplate = CMISService::getContentTemplate();
  }
  if ($content) {
    if (is_resource($content) && get_resource_type($content) == 'stream') {

      // Base64 encode the content on read.
      stream_filter_append($content, 'convert.base64-encode', STREAM_FILTER_READ);
      return CMISRepositoryWrapper::processTemplateAsStream($contentTemplate, array(
        "content" => $content,
        "content_type" => $content_type,
      ));
    }
    else {
      return CMISRepositoryWrapper::processTemplate($contentTemplate, array(
        "content" => base64_encode($content),
        "content_type" => $content_type,
      ));
    }
  }
  else {
    return "";
  }
}