#1
|
|||
|
|||
![]()
Hi,
Been struggling for 3 days on this issue Sending a multipart payload in https to a system API, but when the system receives files in particular, the PDF file it received is empty on viewer and the JPEG is corrupted though the files received are on the same size in terms of bytes from the original file. The file that comes in are in BASE64 but I need to convert it to a binary in multipart before the API consumes it properly. Been trying different charsets but to no success. I tried SoapUI to feed the same files and copied the exact headers but Im getting success on SoapUI than in Mirth/Nextgen connect. ![]() When I also save the decoded base64 using FileUtil, it is viewing OK in the local machine. Below is the code: channelMap.put('AttachmentFileName',msg['RequestPayload']['Attachment']['FileName'].toString()); channelMap.put('ContentType',msg['RequestPayload']['Attachment']['MimeType'].toString()); var base64Content = msg['RequestPayload']['Attachment']['Payload'].toString(); var DecodedDataContent =FileUtil.decode(base64Content); var strDecodedDataContent = new java.lang.String(DecodedDataContent); channelMap.put('BinaryDataBody', strDecodedDataContent); channelMap.put('BoundaryUUID',UUIDGenerator.getUUI D()); FileUtil.write('C:\\Temp\\In\\'+connectorMessage.g etMessageId()+ '_'+msg['RequestPayload']['Attachment']['FileName'].toString(), true, DecodedDataContent); [Separate Transformer] var strHdr = "\r\n--" +$('BoundaryUUID') +"\r\n"; strHdr = strHdr + "Content-Type: "+ $('ContentType') +"; name=" +$('AttachmentFileName') +"\r\n"; strHdr = strHdr + "Content-Transfer-Encoding: binary\r\n"; strHdr = strHdr + 'Content-Disposition: form-data; name="file"; filename="' + $('AttachmentFileName') + '"\r\n'; strHdr = strHdr + "\r\n"; logger.info("MultiPart Header :" + strHdr); strHdr = strHdr + $('BinaryDataBody') +"\r\n"; strHdr = strHdr + "--" + $('BoundaryUUID') + "--\r\n"; channelMap.put("PartContent",strHdr); |
#2
|
|||
|
|||
![]() |
#3
|
|||
|
|||
![]() Quote:
Thanks mate,, I've read that one before and it doesn't help either. Tried examining the data sent by Mirth and I've started to point finger on this statement: var strDecodedDataContent = new java.lang.String(DecodedDataContent) I don't think this is the right java object to use and its default encoding(or probably not the right approach). So i've also tried creating my own custom class(jar file) lib to decode the binary data using java String class but its the same outcome.. Empty PDF and broken JPG.. Im having JRE 1.8.0_152-b16.. Anyway, I gave up on this issue, I initiated plan B and just downloaded the 'Curl' tool and let it do the job on sending the multi-part attachment data to the Jira API. cheers |
![]() |
Thread Tools | |
Display Modes | |
|
|