Exemplo n.º 1
0
        public S3FileStorage(S3FileStorageOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _bucket           = options.Bucket;
            _serializer       = options.Serializer ?? DefaultSerializer.Instance;
            _useChunkEncoding = options.UseChunkEncoding ?? true;
            _cannedAcl        = options.CannedACL;
            _logger           = options.LoggerFactory?.CreateLogger(typeof(S3FileStorage)) ?? NullLogger.Instance;

            var credentials = options.Credentials ?? FallbackCredentialsFactory.GetCredentials();

            if (String.IsNullOrEmpty(options.ServiceUrl))
            {
                var region = options.Region ?? FallbackRegionFactory.GetRegionEndpoint();
                _client = new AmazonS3Client(credentials, region);
            }
            else
            {
                _client = new AmazonS3Client(credentials, new AmazonS3Config {
                    RegionEndpoint    = RegionEndpoint.USEast1,
                    ServiceURL        = options.ServiceUrl,
                    ForcePathStyle    = true,
                    HttpClientFactory = options.HttpClientFactory
                });
            }
        }
Exemplo n.º 2
0
        public S3FileStorage(S3FileStorageOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _credentials = options.Credentials ?? FallbackCredentialsFactory.GetCredentials();
            _region      = options.Region ?? FallbackRegionFactory.GetRegionEndpoint();
            _bucket      = options.Bucket;
            _serializer  = options.Serializer ?? DefaultSerializer.Instance;
        }