Write files to different directories with from one EnsLib.File.OutboundAdapter

I have one Ensemble EnsLib.File.OutboundAdapter which has several methods, each writing a different file. In my Ensemble Production I have configured this FileAdapter to write to a certain directory, but i'd rather have each method write to a different (sub)directory instead of writing all files to the same directory. How can I achieve that without splitting the methods into different business operations?

The current code just sets the filename and the output:

set tSC = ..Adapter.PutString(filename,output)

 

 

Vote up!
Vote down!

Rating: 0

2 answers

Answer

Filename is appended to directory, so if you have a directory: /tmp/ you can call

set tSC = ..Adapter.PutString("old/plan.txt",output)
set tSC = ..Adapter.PutString("new/plan.txt",output)

and it should produce two files /tmp/old/plan.txt and /tmp/new/plan.txt in two different subdirectories. of /tmp

Vote up!
Vote down!

Rating: 1

I guess this means that if you code things to allow the requester to specify the filename you may wish to take precautions against a directory escape exploit.

Vote up!
Vote down!

Rating: 1

Answer

From a technical point Eduard mentioned the most straight forward way.

Another option would be to subclass EnsLib.File.OutboundAdapter. Having only one Put* call.

There for you may introduce a SecondFilePath setting. Overwriting the Put* methods using ##super() could then easiliy produce more than one filecopy.

 

Vote up!
Vote down!

Rating: 0

Log in to answer