SDT FtpsOptions で定義されている認証パラメーターを使用して、サーバーへの SSL/TLS 接続を確立します。
Connect(FtpsOptions)
- 入力 FtpsOptions: 認証設定が事前ロードされた SDT FtpsOptions。
- 戻り値: 接続が成功した場合はブール値 True。
例:
&success = &FtpsClient.Connect(&FtpsOptions)
既に開いている接続を使用して、リモート FTPS サーバーからクライアントマシンにファイルをダウンロードします。
Get(remoteFilePath, localDirectory)
- 入力 remoteFilePath: VarChar(256)。ファイル名および拡張子を含む、作業ディレクトリー (pwd) への相対パス。
- 入力 localDirectory: VarChar(256)。ダウンロードするファイルの保存先となるローカルの絶対パス。
- 戻り値: 操作が成功した場合はブール値 True。
例:
&success = &FtpsClient.Get("/ftpsfolder/samplefile.txt", "C:\Temp\")
既に開いている接続を使用して、ローカルのクライアントマシンから FTPS サーバーにファイルをアップロードします。
Put(localFilePath, remoteDirectory)
- 入力 localFilePath - VarChar(256)。ファイル名および拡張子を含む、ファイルへのローカルの絶対パス。
- 入力 remoteDirectory - VarChar(256)。作業ディレクトリー (pwd) への相対パス。
- 戻り値: 操作が成功した場合はブール値 True。
例:
&success = &FtpsClient.Put("C:\Temp\samplefile.txt", "/ftpsfolder")
既定のリモートサーバーの作業ディレクトリーを返します (pwd コマンド)。
GetWorkingDirectory()
例:
&directory = &FtpsClient.GetWorkingDirectory()
FTPS 接続を終了します。
チャネルの使用が終了したら必ず実施することを優れたプログラミングプラクティスとしてお勧めします。また、セキュリティ対策にもなります。
Disconnect()
例
&FtpsClient.Disconnect()
&FtpsOptions.Host = "172.16.4.5"
&FtpsOptions.User = "dummyuser"
&FtpsOptions.Port = 21
&FtpsOptions.Password = "dummypass"
&FtpsOptions.ForceEncryption = true
&FtpsOptions.ConnectionMode = FtpConnectionMode.PASSIVE
&FtpsOptions.EncryptionMode = FtpEncryptionMode.EXPLICIT
&FtpsOptions.Protocol = FtpsProtocol.TLS1_2
&FtpsOptions.TrustStorePath = "C:\cacerts\truststore.pkcs12"
&FtpsOptions.Encoding = FtpEncoding.BINARY
&success = &FtpsClient.Connect(&ftpsOptions)
&var_error = false
if (&success = true)
&getsuccess = &FtpsClient.Put("C:\temp\testfile.txt", "/ftpstest")
if (&getsuccess = false)
&var_error=true
endif
else
&var_error=true
endif
&FtpsClient.Disconnect()
if (&var_error = true)
if(&FtpsClient.HasError())
msg("Error.Code: " + "&FtpsClient.GetErrorCode() + "Description: " + &FtpsClient.GetErrorDescription())
endif
endif
&FtpsOptions.Host = "172.16.4.5"
&FtpsOptions.User = "dummyuser"
&FtpsOptions.Port = 21
&FtpsOptions.Password = "dummypass"
&FtpsOptions.ForceEncryption = true
&FtpsOptions.ConnectionMode = FtpConnectionMode.PASSIVE
&FtpsOptions.EncryptionMode = FtpEncryptionMode.EXPLICIT
&FtpsOptions.Protocol = FtpsProtocol.TLS1_2
&FtpsOptions.TrustStorePath = "C:\cacerts\truststore.pkcs12"
&FtpsOptions.Encoding = FtpEncoding.BINARY
&success = &FtpsClient.Connect(&ftpsOptions)
&var_error = false
if (&success = true)
&putsuccess = &FtpsClient.Put("C:\temp\testfile.txt", "/ftpstest")
if (&putsuccess = false)
&var_error=true
endif
else
&var_error=true
endif
&FtpsClient.Disconnect()
if (&var_error = true)
if(&FtpsClient.HasError())
msg("Error.Code: " + "&FtpsClient.GetErrorCode() + "Description: " + &FtpsClient.GetErrorDescription())
endif
endif
警告: これらは単なる一例です。パスワードや鍵はハードコーディングしないでください。
|