protected override Yield Stop(Result result) { _s3Client.Dispose(); _s3Client = null; yield return(Coroutine.Invoke(base.Stop, new Result())); result.Return(); }
//--- Methods --- protected override Yield Start(XDoc config, IContainer container, Result result) { yield return(Coroutine.Invoke(base.Start, config, new Result())); // are we a private storage service? _private = config["sid"].Contents == "sid://mindtouch.com/2010/10/dream/s3.storage.private"; _log.DebugFormat("storage is {0}", _private ? "private" : "public"); // is the root blocked from access? _privateRoot = config["private-root"].AsBool.GetValueOrDefault(); _log.DebugFormat("storage root is {0}accessible", _privateRoot ? "not " : ""); // set up S3 client var s3Config = new AmazonS3ClientConfig() { S3BaseUri = new XUri(config["baseuri"].AsText.IfNullOrEmpty("http://s3.amazonaws.com")), Bucket = config["bucket"].AsText, Delimiter = "/", RootPath = config["folder"].AsText, PrivateKey = config["privatekey"].AsText, PublicKey = config["publickey"].AsText, Timeout = TimeSpan.FromSeconds(config["timeout"].AsDouble ?? DEFAULT_S3_TIMEOUT) }; if (string.IsNullOrEmpty(s3Config.Bucket)) { throw new ArgumentException("missing configuration parameter 'bucket'"); } if (string.IsNullOrEmpty(s3Config.PrivateKey)) { throw new ArgumentException("missing configuration parameter 'privatekey'"); } if (string.IsNullOrEmpty(s3Config.PublicKey)) { throw new ArgumentException("missing configuration parameter 'publickey'"); } if (!container.IsRegistered(typeof(IAmazonS3Client))) { // Note (arnec): registering the client in the container to hand over disposal control to the container var builder = new ContainerBuilder(); builder.Register <AmazonS3Client>().As <IAmazonS3Client>(); builder.Build(container); } _s3Client = container.Resolve <IAmazonS3Client>(TypedParameter.From(s3Config)); result.Return(); }
public void Do() { IAmazonS3Client client = this._amazonS3FActory(credentials, config); // do something with client }
public AmazonS3FileStorageService(IAmazonS3Client clientContext) { this.clientContext = clientContext; }
protected override Yield Stop(Result result) { _s3Client.Dispose(); _s3Client = null; yield return Coroutine.Invoke(base.Stop, new Result()); result.Return(); }
//--- Methods --- protected override Yield Start(XDoc config, IContainer container, Result result) { yield return Coroutine.Invoke(base.Start, config, new Result()); // are we a private storage service? _private = config["sid"].Contents == "sid://mindtouch.com/2010/10/dream/s3.storage.private"; _log.DebugFormat("storage is {0}", _private ? "private" : "public"); // is the root blocked from access? _privateRoot = config["private-root"].AsBool.GetValueOrDefault(); _log.DebugFormat("storage root is {0}accessible", _privateRoot ? "not " : ""); // set up S3 client var s3Config = new AmazonS3ClientConfig() { S3BaseUri = new XUri(config["baseuri"].AsText.IfNullOrEmpty("http://s3.amazonaws.com")), Bucket = config["bucket"].AsText, Delimiter = "/", RootPath = config["folder"].AsText, PrivateKey = config["privatekey"].AsText, PublicKey = config["publickey"].AsText, Timeout = TimeSpan.FromSeconds(config["timeout"].AsDouble ?? DEFAULT_S3_TIMEOUT) }; if(string.IsNullOrEmpty(s3Config.Bucket)) { throw new ArgumentException("missing configuration parameter 'bucket'"); } if(string.IsNullOrEmpty(s3Config.PrivateKey)) { throw new ArgumentException("missing configuration parameter 'privatekey'"); } if(string.IsNullOrEmpty(s3Config.PublicKey)) { throw new ArgumentException("missing configuration parameter 'publickey'"); } if(!container.IsRegistered(typeof(IAmazonS3Client))) { // Note (arnec): registering the client in the container to hand over disposal control to the container var builder = new ContainerBuilder(); builder.Register<AmazonS3Client>().As<IAmazonS3Client>(); builder.Build(container); } _s3Client = container.Resolve<IAmazonS3Client>(TypedParameter.From(s3Config)); result.Return(); }
public ImagePersistingGateway(IAmazonS3Client _s3Client, IAwsAssumeRoleHelper _assumeRoleHelper) { s3Client = _s3Client; assumeRoleHelper = _assumeRoleHelper; }