public FtpBinding(FtpConfiguration config, ParameterInfo parameter, TraceWriter trace, FtpAttribute ftpAttribute)
 {
     _config = config;
     _parameter = parameter;
     _trace = trace;
     _ftpAttribute = ftpAttribute;
 }
        public static void UseFtp(this JobHostConfiguration config, FtpConfiguration ftpConfiguration)
        {
            if (config == null)
                throw new ArgumentNullException(nameof(config));

            // Register our extension configuration provider
            config.RegisterExtensionConfigProvider(new FtpExtensionConfig(ftpConfiguration));
        }
示例#3
0
        public static void UseFtp(this JobHostConfiguration config, FtpConfiguration ftpConfiguration)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            // Register our extension configuration provider
            config.RegisterExtensionConfigProvider(new FtpExtensionConfig(ftpConfiguration));
        }
 public async Task<FtpMessage> GetFileAsync(FtpConfiguration config, string path)
 {
     switch (config.FtpHost.Scheme)
     {
         case "sftp":
             return await GetFromSftp(config, path);
         case "ftps":
             return await GetFromFtps(config, path);
         default: throw new ArgumentException("Unsupported uri scheme. Only ftps and sftp is supported.", nameof(config));
     }
 }
 public FtpExtensionConfig(FtpConfiguration ftpConfiguration)
 {
     _ftpConfiguration = ftpConfiguration;
 }
 public FtpClient(FtpConfiguration config)
 {
     _config = config;
 }
        private async Task<FtpMessage> GetFromFtps(FtpConfiguration config, string path)
        {
            var host = config.FtpHost.Host;
            var username = config.Username;
            var password = config.Password;
            var port = config.FtpPort;


            using (var client = new FTPSClient())
            {
                client.Connect(host,
                    new NetworkCredential(username, password),
                    ESSLSupportMode.CredentialsRequired |
                    ESSLSupportMode.DataChannelRequested);

                var ftps = client.GetFile(path);
                var data = ReadToEnd(ftps);
                return new FtpMessage
                {
                    Configuration = config,
                    Data = data,
                    Filename = path
                };
            }
        }
        private async Task<FtpMessage> GetFromSftp(FtpConfiguration config, string path)
        {
            var host = config.FtpHost.Host;
            var username = config.Username;
            var password = config.Password;
            var port = config.FtpPort;

            using (var sftpClient = new SftpClient(host, port, username, password))
            {
                sftpClient.Connect();
                var data = sftpClient.ReadAllBytes(path);
                sftpClient.Disconnect();

                return new FtpMessage
                {
                    Configuration = config,
                    Data = data,
                    Filename = path
                };
            }
        }
示例#9
0
 public FtpExtensionConfig(FtpConfiguration ftpConfiguration)
 {
     _ftpConfiguration = ftpConfiguration;
 }
 public FtpAttributeBindingProvider(FtpConfiguration config, TraceWriter trace)
 {
     _config = config;
     _trace = trace;
 }
 public FtpValueBinder(IFtpClient client, FtpConfiguration config, FtpAttribute ftpAttribute)
 {
     _client = client;
     _config = config;
     _ftpAttribute = ftpAttribute;
 }