FTP(s)
This section covers the library for working with FTP(s) protocol in 1С:Enterprise, OneScript, and CLI. This page describes all the steps required to get started.
Please review the "About external components" section before getting started
Getting Started
This library provides various methods for working with FTP(s) on the client side. Each method accepts a Connection as its first parameter, which can be initialized in one of two ways:
- Using the
CreateConnectionfunction. In this case, a component object is returned that supports a single connection for multiple requests. - Using the
GetConnectionConfigurationfunction. In this case, only a connection description structure is returned. Each function receiving this structure as theConnectionparameter will internally create a new connection and close it upon completion
When performing multiple sequential requests to an FTP server, it is recommended to use a full connection obtained via the CreateConnection function
Proxy Usage
The client supports establishing connections through a proxy server. Proxy settings can be obtained using the GetProxySettings function. The resulting structure must then be passed to either CreateConnection or GetConnectionConfiguration when initiating work
...
ProxyType = "http"; // http, socks5, socks4
ProxyAddress = FunctionParameters["Proxy_IP"];
ProxyPort = FunctionParameters["Proxy_Port"];
ProxyLogin = FunctionParameters["Proxy_User"];
ProxyPassword = FunctionParameters["Proxy_Password"];
ProxySettings = OPI_FTP.GetProxySettings(ProxyAddress, ProxyPort, ProxyType, ProxyLogin, ProxyPassword);
Connection = OPI_FTP.CreateConnection(FTPSettings, ProxySettings, TLSSettings);
Support is provided for socks4, socks5, and http proxy servers
Operation via http-proxy is experimental and may be unstable depending on the proxy server’s implementation, configuration, and capabilities. It is recommended to use socks-proxy whenever possible for stable traffic transmission
FTPS (TLS)
The client also supports secure connections via TLS. To enable it, pass the TLS settings structure to CreateConnection or GetConnectionConfiguration when initiating work. The TLS settings structure can be obtained using the GetTlsSettings function
...
TLSSettings = OPI_FTP.GetTLSSettings(True);
Connection = OPI_FTP.CreateConnection(FTPSettings, ProxySettings, TLSSettings);
If UseProxy Then
ProxyType = FunctionParameters["Proxy_Type"]; // http, socks5, socks4
ProxyAddress = FunctionParameters["Proxy_IP"];
ProxyPort = FunctionParameters["Proxy_Port"];
ProxyLogin = FunctionParameters["Proxy_User"];
ProxyPassword = FunctionParameters["Proxy_Password"];
ProxySettings = OPI_FTP.GetProxySettings(ProxyAddress, ProxyPort, ProxyType, ProxyLogin, ProxyPassword);
EndIf;
If FTPS Then
TLSSettings = OPI_FTP.GetTLSSettings(True);
EndIf;
Connection = OPI_FTP.CreateConnection(FTPSettings, ProxySettings, TLSSettings);