Esempio n. 1
0
 public bool Open(FileServiceConnectionInfo details)
 {
     Details = details;
     if (Details.RetryCount <= 0)
     {
         Details.RetryCount = 1;
     }
     return(Open());
 }
        public FileServiceConnectionInfo ParseConnectionUri(string connectionUri, IEnumerable <KeyValuePair <string, string> > extraOptions)
        {
            var info = new FileServiceConnectionInfo(connectionUri, extraOptions);

            // parse host
            if (info.Port <= 0)
            {
                info.Port = 22;
            }

            info.FullPath = PreparePath(info.FullPath);
            info.BasePath = PreparePath(info.BasePath);

            return(info);
        }
Esempio n. 3
0
        public FileServiceConnectionInfo ParseConnectionUri(string connectionUri, IEnumerable <KeyValuePair <string, string> > extraOptions)
        {
            var info = new FileServiceConnectionInfo(connectionUri, extraOptions);

            // parse host
            if (info.Port <= 0)
            {
                if (info.Location == "ftp")
                {
                    info.Port = 21;
                }
                else if (info.Location == "ftps")
                {
                    info.Port = 990;
                }
                else if (info.Location == "ftpes")
                {
                    info.Port = 21;
                }
            }

            return(info);
        }
Esempio n. 4
0
        public FileServiceConnectionInfo ParseConnectionUri(string connectionUri, IEnumerable <KeyValuePair <string, string> > extraOptions)
        {
            var info = new FileServiceConnectionInfo(connectionUri, extraOptions);

            // initialize list of valid endpoints
            if (awsEndpointMap == null)
            {
                var map = new Dictionary <string, string> (StringComparer.OrdinalIgnoreCase);
                foreach (var endpoint in Amazon.RegionEndpoint.EnumerableAllRegions)
                {
                    map[endpoint.SystemName] = endpoint.SystemName;
                    map[endpoint.SystemName.Replace("-", "")]            = endpoint.SystemName;
                    map[endpoint.GuessEndpointForService("s3").Hostname] = endpoint.SystemName;
                    var hostName = endpoint.GetEndpointForService("s3").Hostname;
                    map[hostName] = endpoint.SystemName;
                }
                awsEndpointMap = map;
            }

            // analise endpoint
            var missingEndpoint = false;

            if (String.IsNullOrWhiteSpace(info.Host))
            {
                info.Host = Amazon.RegionEndpoint.USEast1.SystemName;
            }
            else if (awsEndpointMap.ContainsKey(info.Host))
            {
                info.Host = awsEndpointMap[info.Host];
            }
            else
            {
                // in this case the s3 endpoint is missing and we should expect that the BUCKET name was parsed as the HOST
                // but the uri parse transforms to lowecase the host, so we should parse it again!
                missingEndpoint = true;
                // force the default endpoint, if it is missing
                info.Host = Amazon.RegionEndpoint.USEast1.SystemName;
            }

            // parse bucket name
            if (!missingEndpoint)
            {
                var i = info.FullPath.IndexOf('/', 1);
                if (i < 0)
                {
                    throw new Exception("Invalid S3 file search path");
                }
                info.Set("bucketName", info.FullPath.Substring(0, i).Trim('/'));

                info.FullPath = info.FullPath.Substring(i + 1);
                info.BasePath = info.BasePath.Substring(i + 1);
            }
            else
            {
                // if endpoint is missing, we can assume that the current host is actually the AWS S3 Bucket
                var i = info.ConnectionUri.IndexOf('/', 5); // search for "/" skiping "s3://"
                if (i < 0)
                {
                    throw new Exception("Invalid S3 file search path");
                }
                info.Set("bucketName", info.ConnectionUri.Substring(5, i - 5).Trim('/'));
            }

            return(info);
        }