Archiving Files to Documents |
Scroll |
A Thereforeā¢ document may contain one or more documents (e.g. 2 word documents, a PDF and 3 JPEG images), usually belonging to the same topic or task. These individual documents in a Thereforeā¢ document are often referred to as streams. The Step-by-Step guide illustrates how to archive one or many streams to a document via the Web API.
To archive streams/files to a Therefore document you can use one of the following options:
Option 1. Sending file content as Base64 (XML message encoding, SOAP Endpoints: soapun, soapwin) or as a byte array (JSON/REST Endpoints: restun, restwin)
The following method are used for this option:
oCreateDocument (file data is sent in the Streams parameter in the request);
oUpdateDocument (file data is sent in the Streams parameter in the request);
oAddStreamsToDocument (file data is sent in the Streams parameter in the request).
Option 2. Archiving Files as Binary Data in Chunks. It is the recommended way because this option provides better performance and smaller message size compared to the other options.
The following method are used for this option:
oUploadSessionStart (starts file upload session; one session per file; multiple sessions can be started);
oUploadSessionAppendChunkRaw (upload chunks for each file upload session)
oCreateDocument (put list of the file upload session IDs in the FileUploadSessions parameter in the request);
oUpdateDocument (put list of the file upload session IDs in the FileUploadSessions parameter in the request);
oAddStreamsToDocument (put list of the file upload session IDs in the FileUploadSessions parameter in the request).
Option 3. Batch file upload (to upload multiple files one by one. Deprecated - it is recommended to use option 2 instead).
The following method are used for this option:
Archiving Files as Binary Data in Chunks (recommended)
To create a document with files use chunked file upload approach. For this use the following methods/scenario:
1.First call the UploadSessionStart ā to start file upload session. Keep GUID (session id) returned by the method;
2.Call the UploadSessionAppendChunkRaw ā for each chunk. You can split file content in multiple chunks (let's say by 10 MB) or send it as a single chunk.
Set the following HTTP headers in the request (see example below):
-Content-Type: application/octet-stream
-X-The-UploadSession-ChunkPosition: <integer-chunkposition>
-X-The-UploadSession-Id: <GUID you received in previous step>
3.Call the CreateDocument method with the session id and the file name. Use the FileUploadSessions property in the request instead of the Streams property.
The FileUploadSessions property is an array -> use multiple sessions if you need to save multiple files when creating a document.