No announcement yet.

FTP in file reader

  • Filter
  • Time
  • Show
Clear All
new posts

  • FTP in file reader

    Dear all,

    I want to transfer a file in compressed format (.zip) through FTP but I found out that I can't extract that file in destination.
    Does Mirth support compressed file?
    I need to know exactly how many format files does Mirth support? Could anyone give me document or reference?

    Thank in advance!

  • #2
    If you want to send a ZIP file, it's as easy as sending its Base64 representation using a File Writer in binary mode.

    It sounds like you're trying to extract a ZIP file though right? If so, the package is your friend. For example, I just set up a File Reader channel to read in a ZIP file (in binary mode of course), and pass an XML structure containing all of the extracted files to the destination connector. Here's the code I used for the source transformer:

    var zis = new ZipInputStream(new ByteArrayInputStream(org.apache.commons.codec.binary.Base64.decodeBase64(messageObject.getRawData().replaceAll('[^0-9a-zA-Z\\+\\/\\=]',''))));
    var bufSize = 1024;
    var file;
    while (file = zis.getNextEntry()) {
    	var bos = new ByteArrayOutputStream();
    	var data = getBlankByteArray(bufSize);
    	var len = -1;
    	while ((len =,0,bufSize)) != -1)
    	var fileNode = <file/>; = file.getName();
    	fileNode.content =  new java.lang.String(bos.toByteArray());
    function getBlankByteArray(length) {
    	var bos = new;
    	for (var i = 1; i <= length; i++)
    	return bos.toByteArray();
    I used Delimited Text for my source inbound protocol, XML for the outbound, and "<files/>" for the outbound template. That code doesn't take charsets into consideration, so feel free to add that to the String constructor if necessary.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.

    - How do I foo?
    - You just bar.


    • #3
      Hi narupley,
      Thanks for your reminding. I couldn't transfer a file in compressed format through FTP because data type that i chose wasn't correct.
      And now, it's ok