我正在使用一个系统,该系统按照以下结构在Alfresco存储库上传和下载图像:&#34; root / folder1 / folder2 / image.jpg &#34; < / p>
我设法修复了上传部分,但我正在努力尝试下载图片,我有以下代码:
if(!empty($path)) {
$path = $this->_clientCMIS->getObjectByPath('/'.$path);
$path = ' AND IN_FOLDER(\''.$path->id.'\')';
}
$query = 'SELECT * FROM cmis:document WHERE cmis:name = \''.$file.'\''.$path;
$documents = $this->_clientCMIS->query($query);
foreach ($documents->objectList as $document) {
$data = explode(':', $document->uuid);
array_push($response['data'], array(
'id' => $document->properties['cmis:objectId']
, 'path' => (isset($document->properties['cmis:path']))?$document->properties['cmis:path']:''
, 'name' => $document->properties['cmis:name']
, 'url' => 'http://'.$this->_ip.$this->_port.'/share/proxy/alfresco/api/node/content/workspace/SpacesStore/'.$data[2].'/'.$document->properties['cmis:name']
, 'type' => 'file'
, 'size' => $document->properties['cmis:contentStreamLength']
, 'createdBy' => $document->properties['cmis:createdBy']
, 'creationDate' => $document->properties['cmis:creationDate']
, 'lastModifiedBy' => $document->properties['cmis:lastModifiedBy']
, 'lastModificationDate' => $document->properties['cmis:lastModificationDate']
, 'parentId' => (isset($document->properties['cmis:parentId']))?$document->properties['cmis:parentId']:''
));
}
$response['total'] = sizeof($response['data']);
$response['error'] = '';
我检查了$ path和$ file变量及其值是否正确(存储图像的文件夹和图像的名称),但查询返回一个空对象列表(因此,代码永远不会进入foreach循环)。 $ query变量的值如下所示:
SELECT * FROM cmis:document WHERE cmis:name = 'my_image.jpg' AND IN_FOLDER('workspace://SpacesStore/5acb1737-b30a-2ff8-d47a-7f360c235bd0')
答案 0 :(得分:1)
该查询应该有效。我建议您使用Apache Chemistry OpenCMIS Workbench来测试您的查询(或Alfresco中的节点浏览器)。
可能是您通过身份验证的用户无权访问您要查询的文件夹。
此外,还有一个小问题,但要注意混淆CMIS对象ID的Alfresco节点引用。那些不是一回事。