Handling Multiple Type of Files.

Hi There,

       Let us suppose we have a monitoring directory which receives multiple file types (say XML, Flat File, EDI etc...). We need to separate them. How do we handle this issue. what might be the service we were be using to handle this. What logic do i need to interpret.

Thanks in advance,


When you say monitoring directory, I am assuming file polling. It is always better idea to organize your data hence multiple directories for each type, but if you have to keep the same directory then I would say that the service you are calling can have branch step for multiple types which can be pulled by original file name in the pipeline and depending on the type you can have different child services to process them.

P.S. Even if you aren’t talking about file polling and simply pulling the files from specific directory, you can use the above logic.

Hi Talha Khan,

Thank you so much for the Fast Reply. What you said is absolutely correct. I mean file polling. The efficient way is to use multiple directories for each type of file. lets suppose we use same directory for all the type of files. Using branch how can we differentiate the files? if all the files were EDI files we can differentiate by the Type Name. On what basis we differentiate in the brach step, if there are different types of files. Do we have an inbuilt service for this kind of file handling?

Really appreciate your fast response for my previous question too.

Thank you,

Branch upon the content Type… u need to read the file content to achieve this.



I believe the variable “originalFileName” has the extension which you can parse to do that, or you can create multiple file polling for different types of file monitoring the same directory using “Content Type” in file polling setting. In that way you have more control on the file you process so in future for some reason if you want to stop processing any specific types of file(for limited time period) you can simply disable that port.


HI …Thank you so much for your replies.

Keep in mind that the file polling port will handle the files in different ways depending upon a number of factors.

IS determines the content type of files via the file polling port in 2 ways:

  • If the port is configured with a content type then every file processed from the monitoring directory will be assumed to be of that type. The content handler for that type will be used for all files regardless of extension.

  • If a content type is not configured, then the extension of the filename is used to determine the content type. The lib/mime.types file is used for the mapping.

Different content type handlers put different variables of different types into the pipeline when the top-level service is called. So if the service is to handle different content types as determined by the file extension, then the steps will need to look for the right variables.

My personal preference is to establish directories and file polling ports for each type of file, which is usually associated with one particular integration partner. Having a single drop box can be useful in some situations but you’ll want to weigh that administrative convenience against the complexity of code and the risk of mishandling a file.

Hi Rob,

     Thank you so much for the reply...it was really helpful.

Thank you,

“establish directories and file polling ports for each type of file”-- I agree with Rob and this is the way i have also seen in most engagements which normally avoids code complexity for the gateway service build.