cancel
Showing results for 
Search instead for 
Did you mean: 

Reading multipart form-data in Cloud Integration

rrmalgi
Participant
0 Kudos
222

Hi,

We have a scenario where sender sends form-data as below to Cloud Integration.

However in Cloud Integration we only need to read the main content of the file(SampleCSV.txt)  i.e. "1","2","3,a","4","5" and pass the same to target. Is there a standard way to achieve the same? Please advise

 

----------------------------705490356377119745888137
Content-Disposition: form-data; name="File"; filename="SampleCSV.txt"
Content-Type: text/plain

"1","2","3,a","4","5"
----------------------------705490356377119745888137--

 

Best Regards

View Entire Topic
sivaramaraju_danthuluri
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi ,Can you please try this code 

import com.sap.gateway.ip.core.customdev.util.Message

def Message processData(Message message) {
def body = message.getBody(String)
def boundary = body.split('\n')[0].trim()
def pattern = /(?s)${boundary}.*?Content-Type: text\/plain\s+(.*?)\s+${boundary}--/
def matcher = body =~ pattern

if (matcher.find()) {
def fileContent = matcher.group(1).trim()
message.setBody(fileContent)
}

return message
}