This topic contains 3 replies, has 2 voices, and was last updated by  Casey Trauer 4 years, 11 months ago.

Moving binary files

  • Hi,

    I have downloaded the trial version for evaluation and was trying to do a simple file move from one directory to another. I tried moving a PDF file, which seemed to work but when I tried to open the pdf file it just had a bunch of blank pages. Tried with a Word document and when I tried to open it said it was corrupt.

    My options in source for input file type is ‘Arbitrary Text’. I was expecting to see a choice for binary file. The file does not contain hl7 messages, it is just a report.

    Also, I don’t see, in the destination, how to set the File name to the original incoming name. Is that possible?

    Thanks,
    Rut

    Hi Rut,

    The Iguana message queue is not designed to store binary files. It is designed to move serialized messages in text format. However, if you need to embed binary files in a message, you can read them into Iguana and encode them in base64, and that will make it safe for the Iguana queue. (You will be using a From Translator component instead of a From File component for this. The From File component will try to put anything it reads in into an Iguana queue.)

    There are several strategies you can use to move binary files:

    — You can use Iguana io APIs to do command line actions using popen function to move them from one folder to another. Again, this would mean that you would use a From Translator component instead of a From File component.

    — You can read the binary file into a Translator script and then store it in a SQLite database if you need to reference it from that script or another script. The impact here is that you never need to put the binary file in the queue itself, but you can pass along a reference to it to any other part of the interface logic.

    Hope this helps.

    Casey Trauer,
    Director, Client Education
    iNTERFACEWARE

    Ok. Thanks for the tips. I was hoping to be able to move a file without actually having to process it into the channel, kinda like using ftp to move the file from one directory to another, but not actually using ftp.

    Using your method, I would assume I would still use a To File destination. How do you set the file name to be the same as the original? I would assume it would be in the HL7 message somewhere.

    To be clear, you can do that using io.popen in the scripting environment that you’ll find in From Translator.

    For example, if you are familiar with how to use the operating systems command line interface from say Powershell, you can use those command lines in the io.popen function.

    local Directory = io.popen("ls /path/to/directory")
    local R = Directory:read("*a")

    This is code (for linux) to return a directory listing and read it into Iguana. From there you would parse the filename list, and then you could execute a mv command in popen (or its Windows equivalent) for moving the file to another directory.

    This would the the high-level workflow.

    Casey Trauer,
    Director, Client Education
    iNTERFACEWARE

Tagged: 

You must be logged in to reply to this topic.