// This module is included in these assemblies:
// as_connecting-to-ftp.adoc

[id='adding-ftp-start-connection_{context}']
= Obtaining files from an FTP or SFTP server

To trigger integration execution when an FTP or SFTP connection finds the file(s) you are interested in, add an FTP or SFTP connection as an integration's start connection.

.Prerequisite
You created an FTP or SFTP connection. 

.Procedure

. In the {prodname} panel on the left, click *Integrations*.
. Click *Create Integration*.
. On the *Choose a connection* page, click the 
FTP or SFTP connection that you want to use to poll an FTP or SFTP server. 
. On the *Choose an action* page, select *Download*.
. In the *File name expression* field, type an 
link:{LinkCamelDevGuide}/file[Apache Camel File language] expression that specifies the file or files to download. (Note that you cannot specify a regular expression.)
+
For example, you can filter for all files that have a specific extension from the FTP server. The following example specifies all files with a `.doc` extension:
+
`'${file:onlyname.noext}.doc'`
+
Leave the *File name expression* field blank if you want to download all files in the FTP directory.
+
At runtime, the connection polls (periodically checks) the server for the file or files and downloads them when found.

. In the *FTP directory* field, enter the absolute or relative path of 
the server directory to
poll. The connection watches this directory for any content and downloads
all files when it finds any content.
. In the *Milliseconds before polling starts* field, accept the default 
of *1000* milliseconds or change the number of milliseconds.
. In the *Milliseconds before the next poll* field, accept the default 
of *500* milliseconds or change the number of milliseconds. This is the
interval between polls. 
. In the *Delete after download* field, accept the default of *No*
or select *Yes* to download the file(s) and then delete it(them) from the server.
. Click *Next* to specify the action's output type. 

. In the *Select Type* field, if the data type does not need to be known, 
accept *Type specification not required* 
and click *Next*. You do not need to follow the rest of these
instructions. 
+
However, a structured data type is recommended. For example, if you want 
to map the connection output in a data mapper step then you must specify 
the data type. The data mapper cannot display fields for unstructured data.
+
To specify the data type, click in the *Select Type* field and select one of the following as the schema type:
+
* *JSON schema* is a document that describes the structure of JSON data.
The document's media type is `application/schema+json`. 
* *JSON instance* is a document that contains JSON data. The document's 
media type is `application/json`. 
* *XML schema* is a document that describes the structure of XML data.
The document's file extension is `.xsd`.
* *XML instance* is a document that contains XML data. The
document's file extension is `.xml`. 
* *CSV instance* is a document that contains comma-separated value (CSV) data. The document's file extension is `.csv`. 
ifeval::["{location}" == "downstream"]
+
*Note* _Data Mapper support for CSV data is a Technology Preview feature only._
endif::[]

. In the *Definition* input box, paste a definition that conforms to the
schema type you selected. 
For example, if you select *JSON schema* then you would paste the content of
a JSON schema file, which has a media type of `application/schema+json`.

. In the *Data Type Name* field, enter a name that you choose for the
data type. For example, if you are specifying a JSON schema for
vendors then you might specify `*Vendor*` as the data type name. 
+
You will see this data type name when you are creating 
or editing an integration that uses the connection
for which you are specifying this type. {prodname} displays the type name
in the integration visualization and in the data mapper. 

. In the *Data Type Description* field, provide information that helps you
distinguish this type. This description appears in the data mapper when 
you hover over the step that processes this type. 
. Click *Next*. 

.Result
The connection appears at the beginning of the integration visualization. 
