Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   ShareFile help encoding issue (not sure if mirth or sharefile) (http://www.mirthcorp.com/community/forums/showthread.php?t=221862)

nafwa03 11-28-2019 02:30 PM

ShareFile help encoding issue (not sure if mirth or sharefile)-SOLVED
1 Attachment(s)
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..

nafwa03 11-29-2019 11:08 AM

More info
Ok. so I have determined from more digging that I should be chunking based off of some code samples particularly this:


// 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);

The file sizes are the same as local and are uploaded but they are blank due to junk [] decoded as 7+7 or 77+. I have tried various encoding and all it does is increase the size of the uploaded files but still garbage. Tried on many different pdfs and some not my own. Possibly anyone can help? Before I go down the road to bundle a class jar I figured would ask. Thanks in advance.

nafwa03 11-30-2019 08:13 AM

Many thanks to Kirby on MultiPartEntityBuilder
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)


var pdfContent = "C:\\users\\mirth\\Desktop\\input2.pdf";
var filename = 'input2.pdf';

var entity = org.apache.http.entity.mime.MultipartEntityBuilder
.addBinaryBody("File1", FileUtil.readBytes(pdfContent), org.apache.http.entity.ContentType.create($('contentType')), $('filename')).build();
var bos = new java.io.ByteArrayOutputStream();
msg = FileUtil.encode(bos.toByteArray());

Add this to transformer step2 on destination 4. Change variables or map accordingly. Thats it. Hope this helps someone one day!

All times are GMT -8. The time now is 09:19 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation