Skip to content

edokan/FtpServer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portable FTP server

Build Status

This FTP server is written as .NET Standard 2.0 library and has an abstract file system which allows e.g. Google Drive as backend.

This fork includes new commits from the original repository and from other forks if possible, upgrades to newer nuget dependencies, and uses net9.0 as a new target.

This fork uses edokan as nuget prefix to avoid possible conflicts

License

The library is released under the MIT license.

Support the development

Patreon

Prerequisites

Compilation

  • Visual Studio 2022 / C# 8.0

Using

  • Visual Studio 2022
  • .NET Standard 2.0 (everything except sample application, PAM authentication)
  • .NET Core 3.1 (PAM authentication)
  • .NET Core 9.0

NuGet packages

Package name Description Badge
edokan.FubarDev.FtpServer Core library FubarDev.FtpServer
edokan.FubarDev.FtpServer.Abstractions Basic types FubarDev.FtpServer.Abstractions
edokan.FubarDev.FtpServer.FileSystem.DotNet System.IO-based file system FubarDev.FtpServer.FileSystem.DotNet
edokan.FubarDev.FtpServer.FileSystem.GoogleDrive Google Drive as file system FubarDev.FtpServer.FileSystem.GoogleDrive
edokan.FubarDev.FtpServer.FileSystem.S3 Amazon S3 as file system FubarDev.FtpServer.FileSystem.S3
edokan.FubarDev.FtpServer.FileSystem.InMemory In-memory file system FubarDev.FtpServer.FileSystem.InMemory
edokan.FubarDev.FtpServer.FileSystem.Unix Unix file system FubarDev.FtpServer.FileSystem.Unix
edokan.FubarDev.FtpServer.MembershipProvider.Pam PAM membership provider FubarDev.FtpServer.MembershipProvider.Pam

Example FTP server

Creating the project

dotnet new console
dotnet add package edokan.FubarDev.FtpServer.FileSystem.DotNet
dotnet add package edokan.FubarDev.FtpServer
dotnet add package Microsoft.Extensions.DependencyInjection

Contents of Main in Program.cs

// Setup dependency injection
var services = new ServiceCollection();

// use %TEMP%/TestFtpServer as root folder
services.Configure<DotNetFileSystemOptions>(opt => opt
    .RootPath = Path.Combine(Path.GetTempPath(), "TestFtpServer"));

// Add FTP server services
// DotNetFileSystemProvider = Use the .NET file system functionality
// AnonymousMembershipProvider = allow only anonymous logins
services.AddFtpServer(builder => builder
    .UseDotNetFileSystem() // Use the .NET file system functionality
    .EnableAnonymousAuthentication()); // allow anonymous logins

// Configure the FTP server
services.Configure<FtpServerOptions>(opt => opt.ServerAddress = "127.0.0.1");

// Build the service provider
using (var serviceProvider = services.BuildServiceProvider())
{
    // Initialize the FTP server
    var ftpServerHost = serviceProvider.GetRequiredService<IFtpServerHost>();

    // Start the FTP server
    ftpServerHost.StartAsync(CancellationToken.None).Wait();

    Console.WriteLine("Press ENTER/RETURN to close the test application.");
    Console.ReadLine();

    // Stop the FTP server
    ftpServerHost.StopAsync(CancellationToken.None).Wait();
}

About

Portable FTP server written in .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%