No announcement yet.

Attachment Handling Question

  • Filter
  • Time
  • Show
Clear All
new posts

  • Attachment Handling Question

    Good Day,
    I am attempting to use Mirth to upload several ZIP files via HTTP post to a web service and trying to figure out the best way to handle this.

    In the source connector I am adding the file as an attachment:
    var contents = FileUtil.readBytes(''.toString());
    var encData=FileUtil.encode(contents);
    channelMap.put('varAttachment', validate(encData, '', new Array()));
    Once done, how can I reference it in the HTTP sender? Currently I referencing the ${varAttachment} in the HTTP sender destination content, but I think I have it both as a channelMap and attachment so doubling up on storage/memory usage and seeing out of memory errors as a result.

    Any possibility to point me in the right direction would help, thanks!

  • #2

    I would use the native attachment handler on the source tab and attach the entire message. The article link I posted tells you how to reference it.
    Diridium Technologies, Inc.


    • #3
      Hi pacmano,
      Thanks. I use a database as the source which retrieves the file location, then I attach in the source transformer as shown below. The following your guide put it into a channel map, but resource wise it seems to be quite heavy as it is in a channel map variable and an attachment, is there a way that after making it an attachment I can just reference that in the destination?


      • #4
        In that case, read in the file in the transformer of the destination itself. No need to get it on the source side.

        var contents = FileUtil.readBytes('/tmp/'); // obviously fix the file name
        contents = FileUtil.encode(contents);
        var att = addAttachment(contents,"application/zip");
        $c('token', att.getAttachmentId())

        and in the http sender put in Content

        Obviously I don't know what your remote side really wants. e.g. binary vs base64 encoded.
        Diridium Technologies, Inc.


        • #5
          Beauty, thanks, I'll give it a go!