Let me show you the steps involved in configuring the SSIS FTP task to send multiple files with an example. To send a single file, Please refer FTP Task Send Files article.
NOTE: The SSIS FTP Task uses the FTP Connection Manager to connect with the Remote (FTP Server) Files and Folders.
The following screenshot will show you the data inside the local folder. Our SSIS FTP task is to send multiple files (all the existing files) from the File System Folder to FTP Server’s Root directory.
The below screenshot shows you the data inside the FTP Server.
SSIS FTP Task Send Multiple Files
To send multiple files from the local computer to FTP Server, First Drag and drop the Foreach Loop Container into the Control Flow region
Double-click on it will open the Foreach Loop Editor to configure it. From the below screenshot, you can observe that we are selecting Foreach File Enumerator because we want to loop over the files present in our file system.
Next, click on the Browse button to select the folder name from our file system. From the below screenshot, see that we are choosing the FILE SYSTEM TASK – COPY FILES folder in our E Drive. Click the OK button to select it.
Within the Files section, we have to specify the file type using Wildcards. In this example, we want to send all files (irrespective of extensions) from our local file system to the FTP server, so we are using Wildcard *.*.
TIP: If you want to send only text files, then use: *.txt
Next, we have to store the file names in a variable so that we can use them in our FTP Task. To do that, go to the Variable Mappings section and select the user variable (if any) or create a new variable
Once you click on the <New Variable..>, the Add Variable window will open to create a new variable. In this example, we require variables to store the File name and its extension, for instance, cache.xml. So, we are creating a string variable and assigning the name as Var_FileNames. Click OK to finish creating a string variable.
Now select the created variable and assign it to index 0. Once you complete, Click OK to finish configuring the Foreach Loop Container.
Next, Drag and drop the FTP Task into the Foreach Loop Container and rename it as SSIS FTP Task Send Multiple Files
Double-click on it will open the FTP Task Editor to configure it. Please change the task name according to your requirements and provide a valid description.
Within the Connection section, We have a property called FTPConnection. Clicking on the drop-down arrow, will show the already created FTP Connections (If any), or please click on the <New Connection..> option to create one. In this example, We are using the already created Connection (FTP Connection Manager). Please refer FTP Connection Manager article to know the connection settings
Please click on the File Transfer tab to configure the FTP operations. The following screenshot will show you the available properties in this tab.
The FTP task in SSIS supports eight different operations on Files and Folders. In this example, we want to send multiple files to FTP Server. So, We are selecting the Send Files option from the Operations property
In our previous step, we used the Foreach Loop Container to loop over the files and stored the File names with an extension in a variable called Var_FileNames. So, we are setting the IsLocalPathVariable to True and selecting the User:Var_FileNames variable as LocalVariable.
For the time being, we are declaring the Remote path manually, but in real-time, we recommend using variables. Please click on the browse (…) button beside this option to open the remote directory.
Currently, we don’t have any subfolders in our FTP Server. So, we selected the root directory / as the location and set the OverwriteDetination property to true. It means the SSIS FTP Task will overwrite any existing files (cache.xml and Remove Double Quotes in Excel Sheet using 1.jpg) in the FTP Server.
Click OK to finish configuring the SSIS FTP task send multiple files package. Let’s run and see whether we successfully Copied the .xml, .txt, .JPG, and .xls files from the local File System to FTP Server or Not.
Well, We successfully send the files present inside the File System Folder to FTP Server’s Root directory.