public PcsFtpServer(IPAddress serverAddress)
        {
            // Setup dependency injection
            var services = new ServiceCollection();

            // use %TEMP%/TestFtpServer as root folder
            services.Configure <DotNetFileSystemOptions>(opt => opt
                                                         .RootPath = Directory);

            // 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 = serverAddress.ToString());
            services.Configure <FtpServerOptions>(opt => opt.Port          = Port);

            // Build the service provider
            var serviceProvider = services.BuildServiceProvider();

            // Initialize the FTP server
            serverHost = serviceProvider.GetRequiredService <IFtpServerHost>();
        }
 public FtpServerBridgeService(IFtpServerHost ftpServerHost, ILogger <FtpServerBridgeService> logger)
 {
     _ftpServerHost    = ftpServerHost;
     _ftpServerOptions = Configuration.FtpServerOptions;
     _logger           = logger;
 }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HostedFtpService"/> class.
 /// </summary>
 /// <param name="ftpServerHost">The FTP server host that gets wrapped as a hosted service.</param>
 public HostedFtpService(
     IFtpServerHost ftpServerHost)
 {
     _ftpServerHost = ftpServerHost;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HostedFtpService"/> class.
 /// </summary>
 /// <param name="ftpServerHost">The FTP server host that gets wrapped as a hosted service.</param>
 public HostedFtpService(
     [NotNull] IFtpServerHost ftpServerHost)
 {
     _ftpServerHost = ftpServerHost;
 }