#1
|
|||
|
|||
![]()
Here is my oauth implementation. It works fine and I am trying to stream multi-part. It works but I cannot get these garbage characters out of my pdf. It works great and fine in python and php but not in mirth. Can someone take a look and enlighten me?
I could easily use cURL but I want to know for my own knowledge. Thanks for anyone who can help.. Last edited by nafwa03; 11-30-2019 at 08:02 AM. Reason: solved |
#2
|
|||
|
|||
![]()
Ok. so I have determined from more digging that I should be chunking based off of some code samples particularly this:
Code:
// read from file, and write to outputstream byte[] buf = new byte[1024*1024]; int len; while((len = source.read(buf, 0, buf.length)) >= 0) { target.write(buf, 0, len); } |
#3
|
|||
|
|||
![]()
Adapted some code slightly from this post: https://www.mirthcorp.com/community/...d.php?t=219080
Mapped contenttype to 'application/octet-stream' Ensure "File1" is string for first addBinaryBody argument (this is not documented well) Code:
var pdfContent = "C:\\users\\mirth\\Desktop\\input2.pdf"; var filename = 'input2.pdf'; var entity = org.apache.http.entity.mime.MultipartEntityBuilder .create() .setBoundary($('boundary')) .addBinaryBody("File1", FileUtil.readBytes(pdfContent), org.apache.http.entity.ContentType.create($('contentType')), $('filename')).build(); var bos = new java.io.ByteArrayOutputStream(); entity.writeTo(bos); msg = FileUtil.encode(bos.toByteArray()); |
![]() |
Thread Tools | |
Display Modes | |
|
|