コード例 #1
0
 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));
        }
コード例 #4
0
 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;
 }
コード例 #6
0
 public FtpClient(FtpConfiguration config)
 {
     _config = config;
 }
コード例 #7
0
        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
                };
            }
        }
コード例 #8
0
        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;
 }
コード例 #10
0
 public FtpAttributeBindingProvider(FtpConfiguration config, TraceWriter trace)
 {
     _config = config;
     _trace = trace;
 }
コード例 #11
0
 public FtpValueBinder(IFtpClient client, FtpConfiguration config, FtpAttribute ftpAttribute)
 {
     _client = client;
     _config = config;
     _ftpAttribute = ftpAttribute;
 }