...
Creating a document in the DMS is a bit more complex. In Nuxeo, a document is made up of a document container, think of it as a shell with some metadata attached to it, and the binary/binaries. To create document in the DMS, you must thus first create a container and then add the binary to it.
a) Creating the "container"
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.Create |
This can be called curled as http POST against the DMS as follows:
Code Block |
---|
curl -X POST \ http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.Create \ -H 'authorization: Basic <userAndPassEncoded>' \ -H 'content-type: application/json' \ -d '{"params":{"entity-type":"document","type":"File","name":"<docName>","properties":{"dc:title":"<docName>","pifile:docCategoryID":"<categoryID>"}},"input":"/default-domain/workspaces/Patricia/<documentPath>"}' |
Again, the <userAndPassEncoded> represents a Base64 encoded string of the format 'Username:Password'. So, 'Username:Password' would be represented as 'VXNlcm5hbWU6UGFzc3dvcmQ='.
To determine the <documentPath>, please see below. The <docName> is the name that the new document should have. <categoryID> is the category that the document will be posted into; pleas take that from the Patricia database.
b) Creating the document content
Following successful creation of the container (see above), the following endpoint is used to fill the container with content:
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Blob.Attach |
This can be curled as http POST against the DMS as follows:
Code Block |
---|
curl -X POST \ http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Blob.Attach \ -H 'authorization: Basic <userAndPassEncoded>' \ -H 'content-type: application/json' \ -F '{"params":{"mime-type":"<docMimeType>","document":"/default-domain/workspaces/Patricia/<documentPath>/<docName>","save":"true","xpath":"file:content"}}' \ -F =@/<pathToSourceFile> |
The <mimeType> should be set according to the document type (eg. "text/html" for a html document). <pathToSourceFile> is your local file path of the binary document to upload.
To determine the <documentPath>, please see below. The <docName> is the name that the new document has as per the creation of the container above.
Deleting a document from the DMS
...
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.SetLifeCycle |
This can be called curled as http POST against the DMS as follows:
...