· Aug 14, 2020

Getting Filepath in FTP adapter

Hi All,

i have a issue in getting the complete file path when using the FTP Adapter in service.
EnsLib.FTP.PassthroughService / EnsLib.FTP.InboundAdapter

I need to know the folder name (including sub folder) where the new file is found by the service when looking up for new files. 
The normal file class is working good as expected

More details below,

In the below two examples you can notice folder name is fetched by normal File adapter, but in FTP only the file name is available.

FTP class gives the o/p as
<?xml version="1.0" ?>
<!-- type: Ens.StreamContainer  id: 1028 -->
<StreamContainer xmlns:xsi="" xmlns:s="">


FILE class gives the o/p as
<?xml version="1.0" ?>
<!-- type: Ens.StreamContainer  id: 1025 -->
<StreamContainer xmlns:xsi="" xmlns:s="">

Any help regarding this will be great. (I am new to intersystems)

Thanks in advance !
Arvind Balachandran

Discussion (1)2
Log in or sign up to continue

Hi Arvind,

The FTP Inbound Adapter splits the directory and file name information into two stream attributes called "Filename" and "FTPDir" while the "Filename" attribute of the File Inbound Adapter combines that information in a single field. Although the stream container shows only the Filename attribute in the OriginalFilename property you can still access the FTP directory information from within the stream it contains.

There are several options. You could do this in the business process or operation that receives that stream or you may want to extract that attribute already in your custom business service.

For example if your business service receives pInput of type %Stream.Object, you can retrieve the attributes with



If you don't want to write a complete custom business service containing the EnsLib.InboundAdapter Parameter you could also extend EnsLib.FTP.PassthroughService, and just overwrite the OnProcessInput method and add a couple lines of code that concatenate the path and file name so it will show in OriginalFilename. Example:

Class CustomEnsLib.FTP.PassthroughService Extends EnsLib.FTP.PassthroughService {

Method OnProcessInput(pInput As %Stream.Object, pOutput As %RegisteredObject) As %Status {
If $data(pInput.Attributes("FTPDir")) {
set pInput.Attributes("Filename") = pInput.Attributes("FTPDir") _ pInput.Attributes("Filename")

Like I said, there are several options to achieve this. Please let me know if you have questions.