Plugin: SFTP
Introduction
The plugin provides an easy way to transfer files over the web using SFTP.
Features
Upload file
Upload file using SSH.
Method Name: Upload
Input
- Data: the object contains upload information.
- FileName(required): a string represents a file name to upload.
- Data(required): a file content.
- ReplaceIfExist(optional): default value is false, if true the existing file will be replaced.
- Host(optional): a server host, default value is set from plugin setting.
- Port(optional): a server port, default value is set from plugin setting.
- RootPath(optional): a root path to transfer file, default value is set from plugin setting.
- Username(optional): a username to authenticate, default value is set from plugin setting.
- Password(optional): a password to authenticate, default value is set from plugin setting.
- AuthenticationType(optional): a type to authenticate, it can be password or private key.
- PrivateKey(optional): a private key to authenticate.
- Passphrase(optional): a passphrase to protects the private key.
Output
- Data: the object contains upload information
- IsSuccess: If the transferring is success or not.
Example
var pluginApi = ctx.Use<IPluginApi>();
var uploadData = new
{
FileName = "file_name.csv",
Data = new byte[]{}
};
var parameters = new Dictionary<string, object>()
{
{ "Data", JsonConvert.SerializeObject(uploadData) },
{ "Host", "127.0.0.1" },
{ "Port", 22 }
};
var pluginResult = pluginApi.Invoke("SFTPPlugin", "Upload", parameters);
var output = pluginResult.GetObject("Data");
Upload file using temporary file on server
Upload file via SSH using temporary file on the server, to avoid memory leak in case the file is large.
Method Name: UploadWithFileName
Input
- Data: the object contains upload information.
- FileName(required): a string represents a file name to upload.
- TempFileName(required): a temporary file on the server.
- ReplaceIfExist(optional): default value is false, if true the existing file will be replaced.
- Host(optional): a server host, default value is set from plugin setting.
- Port(optional): a server port, default value is set from plugin setting.
- RootPath(optional): a root path to transfering file, default value is set from plugin setting.
- Username(optional): a username to authenticate, default value is set from plugin setting.
- Password(optional): a password to authenticate, default value is set from plugin setting.
- AuthenticationType(optional): a type to authenticate, it can be password or private key.
- PrivateKey(optional): a private key to authenticate.
- Passphrase(optional): a passphrase to protects the private key.
Output
- Data: the object contains upload information.
- IsSuccess: If the transferring is success or not.
Example
var pluginApi = ctx.Use<IPluginApi>();
var uploadData = new
{
FileName = "file_name.csv",
TempFileName = System.IO.Path.GetTempFileName()
};
var parameters = new Dictionary<string, object>()
{
{ "Data", JsonConvert.SerializeObject(uploadData) },
{ "Host", "127.0.0.1" },
{ "Port", 22 }
};
var pluginResult = pluginApi.Invoke("SFTPPlugin", "UploadWithFileName", parameters);
var output = pluginResult.GetObject("Data");
Installation
Requirements
- Casewhere v2.5 or later
Configuration
Configure the plugin as below:
{
"Host": "127.0.0.1",
"Port": 22,
"Username": // username,
"Password": // password,
"RootPath": "/C:/STFP"
}
Releases
1.1.0 - 19/01/2022
Changelog
- Update plugin parameters to include connection.
Download (login required) SFTP plugin v1.1.0 link to be updated
1.0.0 - 15/07/2021
Changelog
- Upload file.
- Upload file using temporary file on server.
Download (login required) SFTP plugin v1.0.0 link to be updated