/
DR4 - Multi-Part Request

DR4 - Multi-Part Request

Content

Overview

The multipart interface can accept multipart messages (RFC1341(MIME) : 7 The Multipart content type ) with files for a configured and started DocumentRouterInstance.

Each part is saved as a file using the filename from the Content-Disposition header. An index file is created according its schema definition. Each Part is handled individually.

It is possible that some parts can be saved and other parts are rejected for multiple reasons.

The files are archived directly (synchrone). They are temporarily stored in a temp folder, which is deleted after request is handled.

Interface

URL

<Protocol>://<domain>:<Port>/<DocumentRouterPath>/documentrouter?CREATE&instanceName=<Name of the running instance>

Example

https://localhost:8080/KGSAdmin-DR/documentrouter?CREATE&instanceName=FI_I1

Required-Header

Content-Type: multipart/form-data; boundary=<Boundary>

Content-Length: <size of the request>

Host: <HostValue>

Body

--<Boundary>
Content-Disposition: form-data; name="file1"; filename="<filename>"
Content-Type: <contentType>
Content-Length: <Length>
X-index-<Key>: <Value>
Content-Transfer-Encoding: binary

<Content>
--<Boundary>--

X-index-<key> Header

The X-index-<Key> headers are used to build the idx file. Means that <Key> has to be a filed name inside the DR schema. Any number of headers per part is allowed. Make sure that X-Index header fields do have all keys required by schema file (field position > 0)

A special order of the fields is not required.

Example:

X-index-repository: FI

X-index-filename: firstDocument.pdf

X-index-document: acg678he

 

lowercase

content of idx file:

acg678he;firstDocument.pdf;FI

The idx files contains only the values.

field names in Content-Disposition header can’t be changed.

Example for Postman

You can use this sample with postman:

Example 2 for Postman

URI

HTTP POST http://localhost:8090/KGSAdmin-DR-4.0.7/documentrouter?CREATE&instanceName=IndexFileBased

Headers

Content-Type: multipart/form-data; boundary=0kao5EFK-fUENGjSjSlfk3DnForlirbP4

Body

--0kao5EFK-fUENGjSjSlfk3DnForlirbP4 Content-Disposition: form-data; name="file1"; fileName="fileone.pdf" Content-Type: application/pdf Content-Length: 3 X-index-ImageFileName: fileone.pdf X-index-repository: FI x-index-SAP_OBJECT_ID: 100019000000002021 Content-Transfer-Encoding: binary abc --0kao5EFK-fUENGjSjSlfk3DnForlirbP4 Content-Disposition: form-data; name="file2"; fileName="filetwo.pdf" Content-Type: application/pdf Content-Length: 3 X-index-repository: FI X-index-ImageFileName: filetwo.pdf x-index-SAP_OBJECT_ID: 100019000000002021 Content-Transfer-Encoding: binary abc --0kao5EFK-fUENGjSjSlfk3DnForlirbP4--

fileName has to be the same as the content of X-index-ImageFileName. Note: ImageFileName is schema specific and connected to ‘F' or 'f’ letter.

Cache Directory and config

Multipart request can contain files of any size. All files bigger than a certain value will be saved in the cache directory and deleted after processing in: <Instance WorkDirectory>/multipartcache. Make sure that the DocumentRouter has read and write permissions. In certain scenarios it could make sense to change the cache size to prevent to many files in memory and a possible out of memory exception. Configure the default value in bytes in the Instance Config in “Common”-Tab:

When the file exceeds this value it is not stored in memory but saved in the cache directory.

 

Possible Return Codes

Status Code

Message

Description

Status Code

Message

Description

500

e.g.:

"can't handle multipart message"

"request is not a multipart message"

Show a general exception. No file is saved. Possible reasons are a not parsable message or the request is not a multipart message.

409 Conflict

 

This error indicates that no or only a part of the received files are successfully saved. In the body a JSON Array is returned with detailed error code, description, and the filename. Each error has one entry is in the array.

Possible status codes are:

409 - object id already exists

500 - can’t create or write document or idx-file

201 (Created)

-

The files that are send are successfully processed.

Response Bodies

201

400

503

 

Related content

DR4 - Defining DataInterfaces, SIDMappings and Archive Link Mappings
DR4 - Defining DataInterfaces, SIDMappings and Archive Link Mappings
More like this
DR4 - SAP RemoteFunction for DMS communication
DR4 - SAP RemoteFunction for DMS communication
More like this
Update H2 Database from 1.4.199 to 2.2.220
Update H2 Database from 1.4.199 to 2.2.220
Read with this
DR4 - Protocol regarding processed documents
DR4 - Protocol regarding processed documents
More like this
DR4 - Creating and Editing Instances
DR4 - Creating and Editing Instances
Read with this
DR4 - Protocol - Tab
DR4 - Protocol - Tab
More like this