Skip to content

A nuget package which supports SFTP features using SSH.Net. The package has been designed and implemented in a way so that it's easy to extend.

License

Notifications You must be signed in to change notification settings

Cheranga/SFTP.Wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SFTP.Wrapper

This package is a wrapper for SSH.Net. The SFTP features are wrapped in an easy to use request/response design.

Usage

  • Install the nuget package

Install-Package SFTP.Wrapper

  • Register your services
private static void RegisterServices(IServiceCollection services)
{
    //
    // Register services here
    //
    services.AddLogging();
    services.UseSftp(new SftpConfig
    {
        Host = "HOST",
        UserName = "USER NAME",
        Password = "PASSWORD",
        Port = 22
    });
}
  • The package exposes ISftpManager interface, inject it to your class.
//
// Example
//
public class SomeService
{
    private readonly ISftpManager _sftpManager;
    private readonly ILogger<SomeService> _logger;

    public SomeService(ISftpManager sftpManager, ILogger<SomeService> logger)
    {
        _logger = logger;
        _sftpManager = sftpManager;        
    }

    public async Task<GetAllFilesResponse> SomeMethod()
    {
        var listOperation = await _sftpManager.GetAllFilesAsync(new GetAllFilesRequest(@"/home")).ConfigureAwait(false);
        if (listOperation.Status)
        {
            return listOperation.Data;
        }
        else
        {            
            _logger.LogError(listOperation.Message);            
        }
    }
}

About

A nuget package which supports SFTP features using SSH.Net. The package has been designed and implemented in a way so that it's easy to extend.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages