Alfresco 使用apache化学php客户端下载文件

Alfresco 使用apache化学php客户端下载文件,alfresco,cmis,apache-chemistry,Alfresco,Cmis,Apache Chemistry,我需要知道,如果我想下载我在Apache Chemistry Php客户端的repositorio中的cmis:documento,我必须做什么 我在Sitios空间中有一个文件“Test.txt”。。。 我想用浏览器下载Test.txt 我的代码: $client = new CMISService('http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom', 'admin', 'admin'); $

我需要知道,如果我想下载我在Apache Chemistry Php客户端的repositorio中的cmis:documento,我必须做什么

我在Sitios空间中有一个文件“Test.txt”。。。 我想用浏览器下载Test.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' => 
我要做什么来创建一个链接来下载文件? 我不想使用webscript

我想我必须使用getContentStream($obj->id)真的吗?
谢谢。

根据您的文档mime类型和您愿意使用的内容,它可能略有不同,但基本上是您需要执行的操作,如果您使用java:

但是由于您使用的是PHP,我想您应该使用复制相同的逻辑,因此基本上
$client->getContentStream($objId)应以字符串形式返回文件内容

  // 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();
    }