web stats
ShareFile help encoding issue (not sure if mirth or sharefile) - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-28-2019, 02:30 PM
nafwa03 nafwa03 is offline
OBX.1 Kenobi
 
Join Date: Nov 2015
Posts: 27
nafwa03 is on a distinguished road
Default ShareFile help encoding issue (not sure if mirth or sharefile)-SOLVED

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..
Attached Files
File Type: xml Sharefile-Mirth.xml (34.7 KB, 7 views)

Last edited by nafwa03; 11-30-2019 at 08:02 AM. Reason: solved
Reply With Quote
  #2  
Old 11-29-2019, 11:08 AM
nafwa03 nafwa03 is offline
OBX.1 Kenobi
 
Join Date: Nov 2015
Posts: 27
nafwa03 is on a distinguished road
Default More info

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);
        }
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.
Reply With Quote
  #3  
Old 11-30-2019, 08:13 AM
nafwa03 nafwa03 is offline
OBX.1 Kenobi
 
Join Date: Nov 2015
Posts: 27
nafwa03 is on a distinguished road
Default 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)

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());
Add this to transformer step2 on destination 4. Change variables or map accordingly. Thats it. Hope this helps someone one day!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:40 AM.


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