on 2023 Jul 06 8:58 AM
Hi experts,
Last time I asked Steps to implement MDK application to upload photos to Document Management Service then got direction of implementation.
After that I implemented rule to call sendRequest using destination of Document Management Service (SDM) REST API. My application partially worked (folder created) so REST API connection is no problem now.
But when I uploaded photo file to SDM, uploaded content is not expected, binary like "[B@7cfe4c8".
My rule is below (some unnecessary parts for explanation are deleted). I manually created multipart/form-data body and header.
Based on the test result, I should not set variable fileContent directly to multipart body. But I could not find resolution. Could you give me some hint to solve this?
export default function CreateEntity(clientAPI) {
const attachments = clientAPI.getControl('SectionedTable0').getControl('FormCellAttachment0').getValue();
const fileContent = attachments[0].content;
// some logic
return clientAPI.executeAction({
// action of creating folder to SDM : no problem
}).then((r) => {
// Generate multipart header and body
const boundary = '----WebKitFormBoundary' + Math.random().toString(36).substring(2);
let body = '--' + boundary + '\r\n';
// some logic
// Append file content to body => fileContent need to be changed
body += 'Content-Disposition: form-data; name="media"; filename="' + filename + '"\r\n';
body += 'Content-Type: ' + contentType + '\r\n\r\n';
body += fileContent + '\r\n';
body += '--' + boundary + '--';
// Set the headers
const headers = {
'Content-Type': 'multipart/form-data; boundary=' + boundary,
'Content-Length': body.length
};
return clientAPI.executeAction({
'Name': '/myApp/Actions/myEntity/myEntity_CreateFile.action',
'Properties': {
'Target': {
"Service": "/myApp/Services/sdm.service",
"Path": '/root/' + folderName,
"RequestProperties": {"Method": "POST", "Body": body, "Headers": headers}
}
}
})
});
}
Best regards,
Kazuhiko Takata
Request clarification before answering.
Hi @manishmatte1753 ,
At that time, I changed strategy and used SAP Process Automation and SAP Document Management Service. Those are perfectly fit to my requirements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
30 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.