1

我目前在通过化学从 Alfresco 下载文件时遇到问题。

这是我的代码:

// Create the session
$repository = new CMISService($repositoryUrl, $userName, $password);
$uuid = $_GET['uuid'];
$contentData = $repository->getObject($uuid);
$tempurl = $repository->getLastRequestURL();

// TEMPORARY URL IS THIS: "http://193.43.168.90:8082/alfresco/api/-default-/public/cmis/versions/1.1/atom/id?id=6b82d8db-2003-467d-91e3-17a2d27f6a68";

$fp = fopen($tempurl, 'r');
$DMSContent = stream_get_contents($fp);
fclose($fp);

我无法下载该文件,因为它返回“HTTP 请求失败!HTTP/1.1 401 未经授权”。这就像我没有登录到 Alfresco。我怎样才能做到这一点?

4

1 回答 1

2

在使用 Alfresco CMIS 和 Chemistry 时,我有过类似的经历,但还没有开始工作。以下是一种解决方法:

使用 REST api 下载 servlet专门用于获取文件:

https://wiki.alfresco.com/wiki/URL_Addressability#DownloadContentServlet

您需要先获得一张票:

/alfresco/service/api/login?u=用户名&pw=密码

它将在 xml 标记之间返回,您可以轻松地将其解析出来并将其作为 alf_ticket 参数传递给下载 servlet。

问候

于 2015-11-26T13:53:19.617 回答