Path: redb-route/redb.Route.Ftp/FtpComponent.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Ftp/FtpComponent.cs ---- using Microsoft.Extensions.Logging; using redb.Route.Abstractions; using redb.Route.Extensions; using redb.Route.Core; using redb.Route.GenericFile; namespace redb.Route.Ftp; /// /// FTP transport component for redb.Route. /// Scheme: ftp. /// /// URI format: ftp:///remote/path?host=server&port=21&username=admin&password=secret /// /// /// Provides FTP integration powered by FluentFTP: /// polling consumer with glob filtering, idempotency, pre/post-move; /// atomic producer with temp-file upload and auto-create directories. /// Supports passive/active mode and FTPS (FTP over TLS). /// /// public sealed class FtpComponent : ComponentBase { /// public override string Scheme => "ftp"; /// public override IEndpoint CreateEndpoint(EndpointUri uri) { ArgumentNullException.ThrowIfNull(uri); var options = new FtpEndpointOptions(); options.BindFromUri(uri.RawParameters); options.ResolveFilter(Context); // Named ConnectionFactory keeps the server password out of the route URI. if (!string.IsNullOrEmpty(options.ConnectionFactory)) { // A set-but-unknown name fails loud -- never a silent fallback to URI params. var factory = Context.GetRequiredFromRegistry(options.ConnectionFactory); factory.ApplyTo(options, uri); } options.Validate(); return new FtpEndpoint(uri, this, options); } } /// /// FTP endpoint. Creates either a consumer (for polling a remote directory) /// or a producer (for uploading files). The path part of the URI is the remote base directory. /// public sealed class FtpEndpoint : EndpointBase { /// Creates an FTP endpoint. public FtpEndpoint(EndpointUri uri, FtpComponent component, FtpEndpointOptions options) : base(uri, component, options) { } /// The remote base directory path derived from the endpoint URI. public string RemotePath => NormalizeRemotePath(Uri.Path); /// Gets the endpoint options for external access. internal FtpEndpointOptions EndpointOptions => Options; /// public override IProducer CreateProducer() { return new FtpProducer(this, Options, new FtpFileOperations(Options)); } /// public override IConsumer CreateConsumer(IProcessor processor) { ArgumentNullException.ThrowIfNull(processor); return new FtpConsumer(this, processor, Options, new FtpFileOperations(Options)); } private static string NormalizeRemotePath(string path) { if (string.IsNullOrEmpty(path)) return "/"; while (path.Contains("//")) path = path.Replace("//", "/"); if (!path.StartsWith('/')) path = "/" + path; if (path.Length > 1 && path.EndsWith('/')) path = path[..^1]; return path; } }