Example #1
0
        public S3FileSystem(string virtualRoot, string awsAccessKey, string awsSecretKey, string awsBucketName, string awsSaveMediaToS3)
        {
            if (virtualRoot == null)
            {
                throw new ArgumentNullException("virtualRoot");
            }

            if (!virtualRoot.StartsWith("~/"))
            {
                throw new ArgumentException("The virtualRoot argument must be a virtual path and start with '~/'");
            }

            RootPath = IOHelper.MapPath(virtualRoot);
            _rootUrl = IOHelper.ResolveUrl(virtualRoot);

            AwsAccessKey = awsAccessKey;
            AwsSecretKey = awsSecretKey;
            AwsBucketName = awsBucketName;
            AwsSaveMediaToS3 = bool.Parse(awsSaveMediaToS3);

            if (AwsIsValid)
            {
                amazonS3FileSystem = new AmazonS3FileSystem(AwsAccessKey, AwsSecretKey, AwsBucketName);
            }
        }
        public S3FileSystem(string virtualRoot, string awsAccessKey, string awsSecretKey, string awsBucketName, string awsSaveMediaToS3)
        {
            if (virtualRoot == null)
            {
                throw new ArgumentNullException("virtualRoot");
            }

            if (!virtualRoot.StartsWith("~/"))
            {
                throw new ArgumentException("The virtualRoot argument must be a virtual path and start with '~/'");
            }

            RootPath = IOHelper.MapPath(virtualRoot);
            _rootUrl = IOHelper.ResolveUrl(virtualRoot);

            AwsAccessKey     = awsAccessKey;
            AwsSecretKey     = awsSecretKey;
            AwsBucketName    = awsBucketName;
            AwsSaveMediaToS3 = bool.Parse(awsSaveMediaToS3);

            if (AwsIsValid)
            {
                amazonS3FileSystem = new AmazonS3FileSystem(AwsAccessKey, AwsSecretKey, AwsBucketName);
            }
        }
Example #3
0
        public S3FileSystem(string virtualRoot, string awsAccessKey, string awsSecretKey, string awsBucketName, string awsSaveMediaToS3, string awsRegion)
        {
            if (virtualRoot == null)
            {
                throw new ArgumentNullException(nameof(virtualRoot));
            }

            if (!virtualRoot.StartsWith("~/"))
            {
                throw new ArgumentException("The virtualRoot argument must be a virtual path and start with '~/'");
            }

            RootPath = IOHelper.MapPath(virtualRoot);
            _rootUrl = IOHelper.ResolveUrl(virtualRoot);
            
            AwsAccessKey = awsAccessKey;
            AwsSecretKey = awsSecretKey;
            AwsBucketName = awsBucketName;
            AwsSaveMediaToS3 = bool.Parse(awsSaveMediaToS3);

            // [ML] - This isnt ideal, but is the best way i an think of making this paramaterized in the IFileSystemProviderManager

            FieldInfo field = null;

            if (!string.IsNullOrWhiteSpace(awsRegion))
            {
                field = typeof(RegionEndpoint).GetField(awsRegion, BindingFlags.Static | BindingFlags.Public);

                if (field == null)
                {
                    throw new ArgumentException($"No Field found on '{typeof(RegionEndpoint).Name}' with the name '{awsRegion}'");
                }
            }

            AwsRegion = field?.GetValue(null) as RegionEndpoint ?? RegionEndpoint.USWest1;

            if (AwsIsValid)
            {
                _amazonS3FileSystem = new AmazonS3FileSystem(AwsAccessKey, AwsSecretKey, AwsBucketName, AwsRegion);
            }
        }
Example #4
0
        public S3FileSystem(string virtualRoot, string awsAccessKey, string awsSecretKey, string awsBucketName, string awsSaveMediaToS3, string awsRegion)
        {
            if (virtualRoot == null)
            {
                throw new ArgumentNullException(nameof(virtualRoot));
            }

            if (!virtualRoot.StartsWith("~/"))
            {
                throw new ArgumentException("The virtualRoot argument must be a virtual path and start with '~/'");
            }

            RootPath = IOHelper.MapPath(virtualRoot);
            _rootUrl = IOHelper.ResolveUrl(virtualRoot);

            AwsAccessKey     = awsAccessKey;
            AwsSecretKey     = awsSecretKey;
            AwsBucketName    = awsBucketName;
            AwsSaveMediaToS3 = bool.Parse(awsSaveMediaToS3);

            // [ML] - This isnt ideal, but is the best way i an think of making this paramaterized in the IFileSystemProviderManager

            FieldInfo field = null;

            if (!string.IsNullOrWhiteSpace(awsRegion))
            {
                field = typeof(RegionEndpoint).GetField(awsRegion, BindingFlags.Static | BindingFlags.Public);

                if (field == null)
                {
                    throw new ArgumentException($"No Field found on '{typeof(RegionEndpoint).Name}' with the name '{awsRegion}'");
                }
            }

            AwsRegion = field?.GetValue(null) as RegionEndpoint ?? RegionEndpoint.USWest1;

            if (AwsIsValid)
            {
                _amazonS3FileSystem = new AmazonS3FileSystem(AwsAccessKey, AwsSecretKey, AwsBucketName, AwsRegion);
            }
        }