The KGS Document Router is capable of accepting data over HTTP(S). In case the customer wishes to send data over HTTPS, this must be handled by the customer. The webserver (i.e. Apache Tomcat) needs to be enbled with HTTPS for the KGS DocumentRouter to handle requests via HTTPS.
The data is transferred as HTTP-POST and with multipart/form-data body. The document header information is transferred in the URL. One or more components are transferred by the body. This version of the function is particularly suitable for transferring documents consisting of several components into the content repository via the KGS DocumentRouter as a whole. The component information is specified in the header of each part the data in the body.
The request body is in multipart/form-data format. With this format, it is possible to transfer several independent parts to the KGS DocumentRouter. The individual parts have their header and a body
and are in MIME format (RFC 2045, 2046). This MIME format enables several components to be transferred to the KGS DocumentRouter simultaneously.
The result will be an JSON output depicting which parts are uploaded with which result. So an multi response is given while the http response code will be 201 (created) if all uploads where successfully.
Responses
...
HTTP response code
...
Body
...
201
...
Json with separate response codes for every part (should be 201)
Example:
Code Block |
---|
[
{
"statuscode": 201,
"message": ""
},
{
"statuscode": 201,
"message": ""
}
] |
...
400
Json with separate response codes for every part.
...
Content
Table of Contents |
---|
Overview
The multipart interface can accept multipart messages (https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html ) 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> |
X-index-<key> Header
The X-index-<Key> headers are used to build the idx file. 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:
View file | ||
---|---|---|
|
Example 2 for Postman
URI
Code Block |
---|
HTTP POST http://localhost:8090/KGSAdmin-DR-4.0.7/documentrouter?CREATE&instanceName=IndexFileBased |
Headers
Code Block |
---|
Content-Type: multipart/form-data; boundary=0kao5EFK-fUENGjSjSlfk3DnForlirbP4 |
Body
Code Block |
---|
--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--
|
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 | ||
---|---|---|---|---|
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
Code Block |
---|
[
{
"statuscode": |
...
201, "message": " |
...
"
},
{
"statuscode": |
...
201, "message": " |
...
"
}
] |
...
503
Json with error message.
...
400
Code Block |
---|
503
Code Block |
---|
{
"statuscode": 503,
"message": "DR instance IndexFileBased not running."
} |
...
Example
Upload-URL: POST http://localhost:8080/KGSAdmin-DR/documentrouter?create&instanceName=DR_Instance_name
Example sending 1 Document
A document consisting of one or more components is transferred in multipart/form-data format. The following example demonstrates sending a single document:
Document header
Content-Type:multipart/form-data;boundary= A495ukjfasdfddrg4hztzu898aA0jklm
...somemoreheaderinformation...
Content-Length:32413
Content part
--A495ukjfasdfddrg4hztzu898aA0jklm
Content-Disposition: form-data; filename="File_to_be_archived.pdf"
X-compId:data
Content-Type:application/pdf
Content-Length:4242
...4242BytesData...
--A495ukjfasdfddrg4hztzu898aA0jklm--
Example sending 2 documents
Document header
Content-Type:multipart/form-data;boundary= A495ukjfasdfddrg4hztzu898aA0jklm
...somemoreheaderinformation...
Content-Length:32413
Content part
--A495ukjfasdfddrg4hztzu898aA0jklm
Content-Disposition: form-data; filename="test_file.txt"
X-compId: index
Content-Type: text/plain
Content-Length: 7
…7BytesData…
--A495ukjfasdfddrg4hztzu898aA0jklm
Content-Disposition: form-data; filename="test_file.pdf"
X-compId:data1
Content-Type:application/pdf
Content-Length:4242
...4242BytesData...
--A495ukjfasdfddrg4hztzu898aA0jklm--
The KGS DocumentRouter should reply with HTTP code 201 in case the archiving was successful.
Restrictions
Prologe
...