Show/Hide Toolbars

Therefore Web API Programming Interface 1.0

A Thereforeā„¢ document may contain one or more files (e.g., 2 word documents, a PDF, and 3 JPEG images), usually belonging to the same topic or task. These individual files in a Thereforeā„¢ document are often referred to as streams. This step-by-step guide illustrates how to archive one or many streams to a Thereforeā„¢ 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:

oStartCreateDocumentBatch

oStartUpdateDocumentBatch

oUploadDocStreamToBatch

oSubmitCreateDocumentBatch

oSubmitUpdateDocumentBatch

 

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;

 

WebAPI.ArchiveFiles.UploadSessionStart

 

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>

 

WebAPI-ArchiveFiles-UploadSessionAppendChunkRaw-HeaderWebAPI.ArchiveFiles.UploadSessionAppendChunkRaw.Body

 

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.

 

WebAPI.ArchiveFiles.CreateDocument.FileSession

 

 

 

 

 

Ā© 2024 Therefore Corporation, all rights reserved.