使用php 5.4.3将multipart / form-data上传到alfresco

时间:2017-06-14 15:37:11

标签: php curl alfresco

嗨我有一个问题,我可以尝试使用php 5.4.3上传带有属性和元数据的文件到alfresco 5.2,这是我的代码:

  curl_setopt_array($curl, array(
        CURLOPT_PORT => "8080",
        CURLOPT_INFILESIZE => filesize($lo_document['tmp_name']),
        CURLOPT_URL => "http://localhost:8080/alfresco/api/default-/public/alfresco/versions/1/nodes/-root-/children",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => $pam['body'],
        CURLOPT_HTTPHEADER => array(
            "authorization: ".$la_auth['Authorization'],
            "accept: application/json",
             "content-type: multipart/form-data"
        )
));

$ pam [' body']是这样的:

-----------------------60061ddb32c3445516be40d631852702
Content-Disposition: form-data; name="name"

patatas.pdf
-----------------------60061ddb32c3445516be40d631852702
Content-Disposition: form-data; name="nodeType"

mutua:documentoMutualista
-----------------------60061ddb32c3445516be40d631852702
Content-Disposition: form-data; name="filedata"; filename="CS-08940-00227056-1.pdf"
Content-Type: application/pdf

-----------------------60061ddb32c3445516be40d631852702--


这显示此错误:

{"error":{"errorKey":"No disk space available","statusCode":409,"briefSummary":"05140331 No disk space available","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"https://api-explorer.alfresco.com"}}

但是这个错误意味着一个或多个参数错误但我不知道哪个,Server有很多磁盘空间。

有任何帮助吗?任何人都使用ApiRest Alfresco 5.2和PHP?

1 个答案:

答案 0 :(得分:1)

我在浏览器环境中上传带有JavaScript的文件时遇到了类似的问题,该浏览器环境从露天后端返回了状态为409且带有错误密钥No disk space available的邮件,但在Postman中有相同的POST请求或CURL正常运行。

解决方案是添加HTTP标头"content-type: multipart/form-data",因为如果未添加自定义内容类型标头,则该标头已经包含multipart/form-data; boundary=---------------------------41184676334标头。

引用: