如果我想下载一个 cmis:documento,我需要知道我必须做什么 在我的存储库中使用 Apache Chemistry Php 客户端。
我有一个文件,"测试.txt"在 Sitios 空间中......我想下载测试.txt与浏览器...
我的代码:
$client = new CMISService('http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom', 'admin', 'admin');
$path = '/Sitios';
$directorio = $client->getObjectByPath($path);
$objs = $client->getChildren($directorio->id);
foreach ($objs->objectList as $obj)
{
var_dump ($obj);
}
在$obj中,我:
array (size=32)
'alfcmis:nodeRef' => string 'workspace://SpacesStore/c3c903fe-86b6-4db0-8cb2-d5c5dbe913c7' (length=60)
'cmis:isImmutable' => string 'false' (length=5)
'cmis:versionLabel' => string '1.0' (length=3)
'cmis:objectTypeId' => string 'cmis:document' (length=13)
'cmis:description' => string 'descripcion del fichero' (length=23)
'cmis:createdBy' => string 'admin' (length=5)
'cmis:checkinComment' => null
'cmis:creationDate' => string '2016-02-15T01:25:12.76+01:00' (length=28)
'cmis:isMajorVersion' => string 'true' (length=4)
'cmis:contentStreamFileName' => string 'Fichero de texto plano' (length=22)
'cmis:name' => string 'Fichero de texto plano' (length=22)
'cmis:isLatestVersion' => string 'true' (length=4)
'cmis:lastModificationDate' => string '2016-02-15T01:25:12.76+01:00' (length=28)
'cmis:contentStreamLength' => string '21' (length=2)
'cmis:objectId' => string 'c3c903fe-86b6-4db0-8cb2-d5c5dbe913c7;1.0' (length=40)
'cmis:lastModifiedBy' => string 'admin' (length=5)
'cmis:secondaryObjectTypeIds' => string 'P:rn:renditioned' (length=16)
'cmis:contentStreamId' => string 'store://2016/2/15/1/25/c36a749d-43f1-4e31-b46a-de66b4f5634d.bin' (length=63)
'cmis:contentStreamMimeType' => string 'text/plain' (length=10)
'cmis:baseTypeId' => string 'cmis:document' (length=13)
'cmis:changeToken' => null
'cmis:isPrivateWorkingCopy' => string 'false' (length=5)
'cmis:versionSeriesCheckedOutBy' => null
'cmis:isVersionSeriesCheckedOut' => string 'false' (length=5)
'cmis:versionSeriesId' => string 'c3c903fe-86b6-4db0-8cb2-d5c5dbe913c7' (length=36)
'cmis:isLatestMajorVersion' => string 'true' (length=4)
'cmis:versionSeriesCheckedOutId' => null
'cm:title' => string 'Titulo del fichero' (length=18)
'cm:description' => string 'descripcion del fichero' (length=23)
'app:editInline' => string 'true' (length=4)
'cm:lastThumbnailModification' => string 'pdf:1455495914744' (length=17)
'' => string 'Titulo del fichero' (length=18)
public 'renditions' =>
我必须做什么才能创建下载文件的链接?我不想使用网络脚本...
我想我必须使用getContentStream($obj->id(真的吗?谢谢。
根据您的文档 mime 类型和您愿意做的事情,它可能略有不同,但如果您使用的是 java,基本上这就是您需要做的:
// Get the contents of the file Document doc = (Document) session.getObject(id); ContentStream contentStream = doc.getContentStream(); // returns null if the document has no content if (contentStream != null) { String content = getContentAsString(contentStream); System.out.println("Contents of " + filename + " are: " + content); } else { System.out.println("No content."); } ... /** * Helper method to get the contents of a stream * * @param stream * @return * @throws IOException */ private static String getContentAsString(ContentStream stream) throws IOException { StringBuilder sb = new StringBuilder(); Reader reader = new InputStreamReader(stream.getStream(), "UTF-8"); try { final char[] buffer = new char[4 * 1024]; int b; while (true) { b = reader.read(buffer, 0, buffer.length); if (b > 0) { sb.append(buffer, 0, b); } else if (b == -1) { break; } } } finally { reader.close(); } return sb.toString(); }
但是由于您使用的是PHP,我想您应该使用PHP API功能复制相同的逻辑,因此基本上$client->getContentStream($objId);
应该将文件内容作为字符串返回。