Search Results for

    Show / Hide Table of Contents

    Plugin: SFTP

    Introduction

    The plugin provides an easy way to transfer files over the web using SFTP.

    Features

    Upload file

    Upload a file using SSH.

    Method Name: Upload

    Input

    • Data: the object containing upload information.
      • FileName(required): a string representing the name of the file to upload.
      • Data(required): the 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 the file to, default value is set from the plugin setting.
    • Username(optional): a username for authentication, default value is set from the plugin setting.
    • Password(optional): a password for authentication, default value is set from the plugin setting.
    • AuthenticationType(optional): the authentication type; it can be password or private key.
    • PrivateKey(optional): a private key for authentication.
    • Passphrase(optional): a passphrase to protect the private key.

    Output

    • Data: the object containing upload information
      • IsSuccess: Whether the transfer succeeded.

    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 a file via SSH using a temporary file on the server, to avoid memory leaks when the file is large.

    Method Name: UploadWithFileName

    Input

    • Data: the object containing upload information.
      • FileName(required): a string representing the name of the file 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 transfer the file to, default value is set from the plugin setting.
    • Username(optional): a username for authentication, default value is set from the plugin setting.
    • Password(optional): a password for authentication, default value is set from the plugin setting.
    • AuthenticationType(optional): the authentication type; it can be password or private key.
    • PrivateKey(optional): a private key for authentication.
    • Passphrase(optional): a passphrase to protect the private key.

    Output

    • Data: the object containing upload information.
      • IsSuccess: Whether the transfer succeeded.

    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

    In This Article
    Back to top Generated by DocFX