.. _document:
Document
========
.. sidebar:: Note
It is recommended that all documents are created using this process. Using the standard create document process is likely to result in significant performance issues.
Create a large document
"""""""""""""""""""""""
To import a large document, start with a new empty document: `Create an empty document`_
Once the empty document has been created append a file to it using the following process: `Append content stream`_
.. _Create an empty document:
Potential issues
^^^^^^^^^^^^^^^^
:Temporary File Expiration: Temporary files will be overwritten if nothing is appended to them before they expire. The expiration can be configured using the following setting in CMIS Configuration.
.. image:: /_static/img/temporary-file-expiry.PNG
:alt: Temporary File Expiry
.. sidebar:: Register a document
Note that a created document will initially be set to unregistered. To register the document, use the updateproperties service to change the isregistered property value to true.
Create an empty document
""""""""""""""""""""""""
Note that a created document will initially be set to unregistered. To register the document, use the updateproperties service to change the ``isregistered`` property value to true.
Empty documents cannot be registered until a content stream has been set. Once this has been set, they will become normal documents.
Sample request
^^^^^^^^^^^^^^
.. code-block:: xml
POST https://test.test.com/testO.Web.Start/testSQL/Api/CMIS/T1/children/?id=ROOTFOLDER HTTP/1.1
Host: test.test.com
Content-Length: 903
urn:uuid:00000000-0000-0000-0000-00000000000
Test
2014-11-24T05:01:37.891Z
t1DocumentType
Test Precis
Empty
Sample response
^^^^^^^^^^^^^^^
.. code-block:: xml
HTTP/1.1 201 Created
Cache-Control: private
Content-Type: application/atom+xml;type=entry
Location: https://test.test.com/testO.Web.Start/testSQL/Api/CMIS/T1/object/?id=document-599949
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-UA-Compatible: IE=edge
Strict-Transport-Security: max-age=10886400
Date: Wed, 05 Oct 2016 07:10:17 GMT
Content-Length: 19034
document-599949
Document 599949
2016-10-05T17:09:24+10:00
2016-10-05T17:09:24+10:00
2016-10-05T17:09:24.427+10:00
cmis:document
2016-10-05T17:09:24+10:00
false
true
true
true
1
false
2016-10-05T17:09:24+10:00
TECHONE
TECHONE
Test Precis
Test Precis
document-599949
t1documenttype
0
565695
false
/folder-565695/document-599949
document-599949
1
1900-01-01T00:00:00+10:00
1900-01-01T00:00:00+10:00
0
0
2016-10-05T17:09:24+10:00
2016-10-05T17:09:24+10:00
288
0
0
false
false
1900-01-01T00:00:00+10:00
0
584
true
2016-10-05T17:09:24.427+10:00
599949
565695
6
Unknown
0
Test Precis
2016-10-05T17:09:24.427+10:00
2016-10-05T17:09:24.427+10:00
0
1900-01-01T00:00:00+10:00
1900-01-01T00:00:00+10:00
584
0
0
1
false
true
false
true
true
false
false
false
false
false
false
false
false
true
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
document-599949
document-599949
.. _Append content stream:
Append content stream
"""""""""""""""""""""
This service allows for large files to be created without significantly impacting the server. Each file is broken into ‘chunks’ and submitted separately. These chunks are merged into one file on the server and then processed once the last chunk has been received.
Parallel requests should ensure that they do not call this service on the same document. A temporary file will be created for each document, however no attempt is made to distinguish between callers. Chunks will be appended to the temporary file in the order that they are received.
Note that if uploading an xml file using this service a content-type header value of raw will be required. Xml files without this value will return an error.
C# sample
^^^^^^^^^
.. code-block:: c#
public void AppendContentStream(string targetId, IContentStream contentStream)
{
var buffer = new byte[ByteArraySize];
int bytesRead;
var firstRun = true;
while ((bytesRead = contentStream.Stream.Read(buffer, 0, buffer.Length)) > 0)
{
AppendDocumentRequest(contentStream.FileName, buffer.Take(bytesRead).ToArray(), false, firstRun, targetId);
firstRun = false;
}
AppendDocumentRequest(contentStream.FileName, null, true, firstRun, targetId);
}
private void AppendDocumentRequest(string fileName, byte[] buffer, bool isLastChunk, bool overwriteFlag, string targetId)
{
var url = $"{BaseUrl}/content/?id={targetId}&isLastChunk={isLastChunk}&append=true";
using (var client = new WebClient())
{
client.Headers.Add(HttpRequestHeader.Authorization, "Basic " + Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("cmis:cmis")));
client.Headers.Add("Content-Disposition", $"attachment; filename=\"{fileName}\"");
if(!isLastChunk)
{
client.UploadData(url, WebRequestMethods.Http.Put, buffer);
}
else
{
client.UploadValues(url, WebRequestMethods.Http.Put, new NameValueCollection());
}
}
}
Sample request
^^^^^^^^^^^^^^
.. code-block:: text
POST https://ecmpartner.onespresso.net/T1Dev/CiAnywhere/Web/DEV/Api/CMIS/T1/content/?id=document-10000&isLastChunk=false&append=true HTTP/1.1
Authorization: Basic Q01JUzpDTUlTcXVhbGl0eQ==
Content-Length: 19
Host: ecmpartner.onespresso.net
first chunk content
Sample response
^^^^^^^^^^^^^^^
.. code-block:: xml
HTTP/1.1 201 Created
Cache-Control: private
Content-Type: application/atom+xml;type=entry
Content-Location: https://ecmpartner.onespresso.net/T1Dev/CiAnywhere/Web/DEV/Api/CMIS/T1/content/?id=document-10000
Location: https://ecmpartner.onespresso.net/T1Dev/CiAnywhere/Web/DEV/Api/CMIS/T1/content/?id=document-10000
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-UA-Compatible: IE=edge
Strict-Transport-Security: max-age=10886400
Date: Mon, 07 Aug 2017 07:35:05 GMT
Content-Length: 252
uuid:2d25450e-1f6f-481e-b242-1bc3f805ef02;id=1
File Size
2017-08-07T07:35:05Z
19
Retrieve a Document Content Stream
""""""""""""""""""""""""""""""""""
A document's content stream can be retrieved by making a GET request to ``/content`` and passing through an id parameter containing the document's id. Note that additional rendition types can be retrieved based on the id passed to this service.
+------------------+-----------------------------------------------------------------------+
|document-2988 | Retrieves the original version of document 2988 |
+------------------+-----------------------------------------------------------------------+
|folder-2534 | Retrieves the original version of the latest document in folder-2534 |
+------------------+-----------------------------------------------------------------------+
|streamorig-2988 | Retrieves the original version of document 2988 |
+------------------+-----------------------------------------------------------------------+
|streampdf-2988 | Retrieves the pdf rendition of document 2988 |
+------------------+-----------------------------------------------------------------------+
|streamthumbl-2988 | Retrieves the large thumbnail of document 2988 |
+------------------+-----------------------------------------------------------------------+
|streamthumbs-2988 | Retrieves the small thumbnail of document 2988 |
+------------------+-----------------------------------------------------------------------+
.. _downloaddirect:
.. Hint::
The default behavior for browser viewable files is to be viewed inline. These can now be downloaded directly by adding the parameter
&forcedownload=true
C# sample
^^^^^^^^^
Please note that the following examples assume that dotCMIS is being used.
.. code-block:: C#
// Retrieve a content stream via document object
largeDocument.GetContentStream();
// Retrieves the original file of the specified document object
session.GetContentStream(new ObjectId("document-2988"));
Sample request
^^^^^^^^^^^^^^
.. code-block:: xml
GET https://ecmpartner.onespresso.net/T1Dev/CiAnywhere/Web/DEV/Api/CMIS/T1/content/?id=document-2988 HTTP/1.1
User-Agent: Apache Chemistry DotCMIS
Authorization: Basic Q01JUzpDTUlTcXVhbGl0eQ==
Host: ecmpartner.onespresso.net
Sample response
^^^^^^^^^^^^^^^
.. code-block:: xml
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: image/png
Server: Microsoft-IIS/7.5
X-Filename: ECM_2534_v1_New Test 4 01 2017 11 21 14 AM.png
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-UA-Compatible: IE=edge
Strict-Transport-Security: max-age=10886400
Date: Wed, 04 Jan 2017 01:49:06 GMT
Content-Length: 3117
PNG (Truncated)
Retrieve a Document Set Content Stream
""""""""""""""""""""""""""""""""""""""
Different content streams for the current version document cann be retrieved directly from the document set.
To retrieve streams other than the original, both the id parameter and the stream parameter must be provided.
This request can be used for all stream types.
**id=folder-2534&streamId=streampdf-2534** will retrieve the pdf rendition of the current version document for document set 2534.
Sample request
^^^^^^^^^^^^^^
::
GET https://ecmpartner.onespresso.net/T1Dev/CiAnywhere/Web/DEV/Api/CMIS/T1/content/?id=folder-2534&streamId=streampdf-2534 HTTP/1.1
Authorization: Basic Q01JUzpDTUlTcXVhbGl0eQ==
Host: ecmpartner.onespresso.net
Sample response
^^^^^^^^^^^^^^^
::
HTTP/1.1 200 OK
Content-Type: application/pdf
X-Filename: ECM_2534_v1_New Test.pdf
Content-Length: 3117
PDF (Truncated)