我正在尝试使用以下命令将文件上传到Alfresco WS restful:
C:\Users\user>curl -v -k -X POST --user admin:admin -F filedata=C:/temp/wpapper.pdf -F siteid=documents -F containerid=documentLibrary -F uploaddirectory=PUBLIC -F filename=wpapper.pdf -F contenttype="application/pdf" http://10.1.1.55:8080/alfresco/service/api/upload
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 10.1.1.55...
* Connected to 10.1.1.55 (10.1.1.55) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /alfresco/service/api/upload HTTP/1.1
> Host: 10.1.1.55:8080
> Authorization: Basic Z2xvbWFyb246c2VxMDk4
> User-Agent: curl/7.46.0
> Accept: */*
> Content-Length: 715
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------5ee452c8955311dc
>
< HTTP/1.1 100 Continue
< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Cache-Control: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Pragma: no-cache
< Content-Type: application/json;charset=UTF-8
< Content-Length: 362
< Date: Wed, 18 May 2016 14:03:47 GMT
< Connection: close
<
{
"status" :
{
"code" : 400,
"name" : "Bad Request",
"description" : "Request sent by the client was syntactically incorrect."
},
"message" : "Required parameters are missing",
"exception" : "",
"callstack" :
[
],
"server" : "Community v5.1.0 (r122274-b3) schema 9.016",
"time" : "18/05/2016 10:03:47"
}
* Closing connection 0
Alfresco's manual for File upload:
将文件内容和元数据上传到存储库。
POST /alfresco/service/api/upload
HTML表单数据
- filedata,(必填)HTML类型文件
- 您必须指定以下其中一项:
- destination(将创建节点的文件夹NodeRef)
- updateNodeRef(将更新的现有节点的NodeRef)
- siteid和containerid(网站名称和该网站中的容器&gt;将在其中创建文档)。
- uploaddirectory - 文档上传文件夹的名称(在网站容器或目标中)。此文件夹必须已存在
- description - 版本更新说明(versionDescription)
- contenttype - 此文档应专门用于
的内容类型- majorversion
- 重写
- 缩略图
返回内容
- nodeRef
返回状态:STATUS_OK(200)
Web脚本描述文档指定以下选项:
_________________________________________ Value ------ Description ___________________________________________ json -------> The default response format user -------> The authentication access required ---> The transaction level any The format style ___________________________________________
PS:目录“PUBLIC”和网站“文档”已经存在。
答案 0 :(得分:1)
其中一种方法是使用Chrome打开Developer工具,通过Share上传文件。在网络上 - &gt; XHR选项卡您将看到上传请求,然后右键单击并选择&#34;复制为cURL&#34;。然后,您可以粘贴cURL命令并根据需要进行调整。