File attachments
It is possible to attach a file to a data record in the monitor. This gives users the option of viewing or downloading the file.
File source
Files in OpenSearch
You can save files in BPC OpenSearch. In this case, a file is attached directly to the monitor data record.
The files should be encoded as a Base64 string and stored in the data record at dataIndex.
So that the file can be restored with the correct name and format, the data record must contain the following information:
-
Name of the file
-
MIME type
The data record containing the file can be added via a BPC log service or via an index request to OpenSearch. The following example shows a data record with a file attachment:
{
"PROCESSID": "2",
"TEXT": "This is second test object",
"FILEID": "foodmenu.xml",
"filename": "foodmenu.xml",
"contentType": "application/xml",
"DATA": "PGJyZWFrZmFzdF9tZW51Pgo8Zm9vZD4KPG5hbWU+QmVsZ2lhbiBXYWZmbGVzPC9uYW1lPgo8cHJpY2U+JDUuOTU8L3ByaWNlPgo8ZGVzY3JpcHRpb24+VHdvIG9mIG91ciBmYW1vdXMgQmVsZ2lhbiBXYWZmbGVzIHdpdGggcGxlbnR5IG9mIHJlYWwgbWFwbGUgc3lydXA8L2Rlc2NyaXB0aW9uPgo8Y2Fsb3JpZXM+NjUwPC9jYWxvcmllcz4KPC9mb29kPgo8Zm9vZD4KPG5hbWU+U3RyYXdiZXJyeSBCZWxnaWFuIFdhZmZsZXM8L25hbWU+CjxwcmljZT4kNy45NTwvcHJpY2U+CjxkZXNjcmlwdGlvbj5MaWdodCBCZWxnaWFuIHdhZmZsZXMgY292ZXJlZCB3aXRoIHN0cmF3YmVycmllcyBhbmQgd2hpcHBlZCBjcmVhbTwvZGVzY3JpcHRpb24+CjxjYWxvcmllcz45MDA8L2NhbG9yaWVzPgo8L2Zvb2Q+Cjxmb29kPgo8bmFtZT5CZXJyeS1CZXJyeSBCZWxnaWFuIFdhZmZsZXM8L25hbWU+CjxwcmljZT4kOC45NTwvcHJpY2U+CjxkZXNjcmlwdGlvbj5MaWdodCBCZWxnaWFuIHdhZmZsZXMgY292ZXJlZCB3aXRoIGFuIGFzc29ydG1lbnQgb2YgZnJlc2ggYmVycmllcyBhbmQgd2hpcHBlZCBjcmVhbTwvZGVzY3JpcHRpb24+CjxjYWxvcmllcz45MDA8L2NhbG9yaWVzPgo8L2Zvb2Q+Cjxmb29kPgo8bmFtZT5GcmVuY2ggVG9hc3Q8L25hbWU+CjxwcmljZT4kNC41MDwvcHJpY2U+CjxkZXNjcmlwdGlvbj5UaGljayBzbGljZXMgbWFkZSBmcm9tIG91ciBob21lbWFkZSBzb3VyZG91Z2ggYnJlYWQ8L2Rlc2NyaXB0aW9uPgo8Y2Fsb3JpZXM+NjAwPC9jYWxvcmllcz4KPC9mb29kPgo8Zm9vZD4KPG5hbWU+SG9tZXN0eWxlIEJyZWFrZmFzdDwvbmFtZT4KPHByaWNlPiQ2Ljk1PC9wcmljZT4KPGRlc2NyaXB0aW9uPlR3byBlZ2dzLCBiYWNvbiBvciBzYXVzYWdlLCB0b2FzdCwgYW5kIG91ciBldmVyLXBvcHVsYXIgaGFzaCBicm93bnM8L2Rlc2NyaXB0aW9uPgo8Y2Fsb3JpZXM+OTUwPC9jYWxvcmllcz4KPC9mb29kPgo8L2JyZWFrZmFzdF9tZW51Pg=="
}
|
The fields |
File reference from INUBIT
Files can be stored in the INUBIT. How files are stored there depends on the setting in the INUBIT.
The files should be provided via a REST endpoint so that they can be downloaded from the BPC (see also Configuration of downloading files in the monitor).
Configuration of downloading files in the monitor
After a file or a reference to the file has been saved on the monitor data set, the following settings are required to enable the file to be downloaded.
Configuration: File column
Specify in the configuration which column contains the file or the reference to the file in the INUBIT.
The setting is called Monitor_FileReferenceColumn (ID: column_file).
If the file is stored in OpenSearch, the content of the set file column is decoded as a Base64 string when downloading.
|
If the file cannot be found or encoded in OpenSearch, the content of the file column is used as a file reference in the INUBIT.
In this case, the content of the file column is sent as the URL Parameters |
Configuration: Downloading from INUBIT
If the file is to be downloaded from INUBIT, the following settings are required:
-
Function_InubitBackendConnection(inubit_proxyId):
INUBIT Backend Connection. -
Function_InubitBaseURL(inubit_baseUrl):
Fixed component in all URLs to INUBIT. -
Function_FileDownloadEndpoint(inubit_referenceEndpoint):
The INUBIT endpoint under which files can be downloaded should be set. -
Monitor_ProcessID(column_id):
The query contains information about the process ID as URL Parameters, therefore the corresponding column should be set. -
Monitor_HistoryID(column_historyId):
If the download refers to the child process, the ID of the child process should be included in the query for the INUBIT as a URL parameter. The associated column must therefore be set.
Once everything has been configured, the URL has the following structure:
{Protokoll}://{Domain}/{inubit_baseUrl}/{inubit_referenceEndpoint}?directory={Inhalt der Datei-Spalte}&processid={processId}&childid={childId}
Configuration: "Download" action
The downloading of files can be triggered via an attachment column (attachment column).
The configuration of the column looks as follows:
{
"xtype": "attachmentColumn",
"width": 200,
"minWidth": 64,
"text": "Download"
}
Specific use case
This example shows how a Base64-encoded file can be written to OpenSearch via the log service and then downloaded from the monitor child grid.
Creating a log service instance
The log service instance is configured with the following parameters:
-
Instance ID:
myTestLogger -
OpenSearch index:
myTestIndex -
OpenSearch history index:
myTestChildIndex
Writing data to OpenSearch via the log service API
The data to be saved contains a Base64-encoded file. This should be stored in a separate file.
In this example, a file named logservice.json is created with the following content:
{
"entries": [
{
"parent": {
"processid": 3,
"name": "hello world",
"lastupdate": "2017-05-17T15:28:23.181Z"
},
"children": [
{
"parentid": 3,
"childid": 1,
"langertext": "Dieser Text",
"lastupdate": "2017-05-17T15:28:23.181Z",
"datei": "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACAQMAAABIeJ9nAAAABlBMVEUAAAD///+l2Z/dAAAADElEQVQIHWNwYGgAAAFEAMGoX3f9AAAAAElFTkSuQmCC",
"filename": "food.png",
"contentType": "application/png"
}
]
}
]
}
Important attributes:
-
datei- contains the Base64-encoded file. -
contentType- specifies the MIME type of the file. -
filename- The name under which the file is to be saved.
Send data to the Logservice API via cURL
In the next step, the data is sent to the Logservice API using the cURL command.
Prerequisites:
curl -H "X-ApiKey: 1f697af5-c147-3d94-c529-e06f3f15bb87" \
-H "Content-Type: application/json" \
-XPOST 'http://localhost:8181/cxf/bpc-logservice/log/myTestLogger' \
-d @logservice.json
Creating a monitor instance
The monitor instance requires the following configuration:
-
OpenSearch Index (
data_index):myTestIndex -
OpenSearch history index (
data_history_index):myTestChildIndex -
Column ID (
column_id):processid -
History ID (
column_historyId):parentid -
Additional History ID (
column_historySubId):childid -
File Reference Column (
column_file):datei -
Backend Connection (
inubit_proxyId): Selection of the created BackendConnection -
Inline detail view (
detailView_inline):true