internal static S3ClientCache CreatClientCacheFromContext(DynamoDBContext context) { var client = ((AmazonDynamoDBClient)context.Client); var cache = new S3ClientCache(client.GetCredentials(), client.CloneConfig <AmazonS3Config>()); lock (S3Link.cacheLock) { S3Link.Caches[context] = cache; } return(cache); }
internal static S3ClientCache CreatClientCacheFromContext(DynamoDBContext context) { var client = ((AmazonDynamoDBClient)context.Client); var cache = new S3ClientCache(client); lock (S3Link.cacheLock) { S3Link.Caches[context] = cache; } return(cache); }
///// <summary> ///// Allows the use of a specific config in the creation of the client for a context ///// </summary> ///// <param name="context">The context the client should be used in</param> ///// <param name="config">The config object for the client</param> //public static void UseConfigForClient(DynamoDBContext context, AmazonS3Config config) //{ // var castedClient = ((AmazonDynamoDBClient)context.Client); // var client = new AmazonS3Client(castedClient.GetCredentials(), config); // S3ClientCache cache; // if (!S3Link.Caches.TryGetValue(context, out cache)) // { // cache = new S3ClientCache(castedClient.GetCredentials(),castedClient.CloneConfig<AmazonS3Config>()); // S3Link.Caches.Add(context, cache); // } // cache.UseClient(client, config.RegionEndpoint); //} /// <summary> /// Creates an S3Link that can be used to managed an S3 connection /// </summary> /// <param name="context">The context that is handling the S3Link</param> /// <param name="bucket">The bucket the S3Link should manage</param> /// <param name="key">The key that S3Link should store and download from</param> /// <param name="region">The region of the S3 resource</param> /// <returns>A new S3Link object that can upload and download to the target bucket</returns> public static S3Link Create(DynamoDBContext context, string bucket, string key, Amazon.RegionEndpoint region) { S3ClientCache cacheFromKey; if (S3Link.Caches.TryGetValue(context, out cacheFromKey)) { return(new S3Link(cacheFromKey, bucket, key, region.SystemName)); } S3ClientCache cache = CreatClientCacheFromContext(context); return(new S3Link(cache, bucket, key, region.SystemName)); }
internal S3Link(S3ClientCache clientCache, string json) { if (clientCache == null) { throw new ArgumentNullException("clientCache"); } if (json == null) { throw new ArgumentNullException("json"); } this.s3ClientCache = clientCache; linker = JsonMapper.ToObject <LinkInfo>(json); }
private S3Link(S3ClientCache clientCache, LinkInfo linker) { if (linker == null) { throw new ArgumentNullException("linker"); } if (clientCache == null) { throw new ArgumentNullException("clientCache"); } this.s3ClientCache = clientCache; this.linker = linker; }
///// <summary> ///// Allows the use of a specific config in the creation of the client for a context ///// </summary> ///// <param name="context">The context the client should be used in</param> ///// <param name="config">The config object for the client</param> //public static void UseConfigForClient(DynamoDBContext context, AmazonS3Config config) //{ // var castedClient = ((AmazonDynamoDBClient)context.Client); // var client = new AmazonS3Client(castedClient.GetCredentials(), config); // S3ClientCache cache; // if (!S3Link.Caches.TryGetValue(context, out cache)) // { // cache = new S3ClientCache(castedClient.GetCredentials(),castedClient.CloneConfig<AmazonS3Config>()); // S3Link.Caches.Add(context, cache); // } // cache.UseClient(client, config.RegionEndpoint); //} /// <summary> /// Creates an S3Link that can be used to managed an S3 connection /// </summary> /// <param name="context">The context that is handling the S3Link</param> /// <param name="bucket">The bucket the S3Link should manage</param> /// <param name="key">The key that S3Link should store and download from</param> /// <param name="region">The region of the S3 resource</param> /// <returns>A new S3Link object that can upload and download to the target bucket</returns> public static S3Link Create(DynamoDBContext context, string bucket, string key, Amazon.RegionEndpoint region) { S3ClientCache cacheFromKey; if (S3Link.Caches.TryGetValue(context, out cacheFromKey)) { return new S3Link(cacheFromKey, bucket, key, region.SystemName); } var client = ((AmazonDynamoDBClient)context.Client); S3ClientCache cache = new S3ClientCache(client.GetCredentials(), client.CloneConfig<AmazonS3Config>()); lock (S3Link.cacheLock) { S3Link.Caches.Add(context, cache); } return new S3Link(cache, bucket, key, region.SystemName); }
///// <summary> ///// Allows the use of a specific config in the creation of the client for a context ///// </summary> ///// <param name="context">The context the client should be used in</param> ///// <param name="config">The config object for the client</param> //public static void UseConfigForClient(DynamoDBContext context, AmazonS3Config config) //{ // var castedClient = ((AmazonDynamoDBClient)context.Client); // var client = new AmazonS3Client(castedClient.GetCredentials(), config); // S3ClientCache cache; // if (!S3Link.Caches.TryGetValue(context, out cache)) // { // cache = new S3ClientCache(castedClient.GetCredentials(),castedClient.CloneConfig<AmazonS3Config>()); // S3Link.Caches.Add(context, cache); // } // cache.UseClient(client, config.RegionEndpoint); //} /// <summary> /// Creates an S3Link that can be used to managed an S3 connection /// </summary> /// <param name="context">The context that is handling the S3Link</param> /// <param name="bucket">The bucket the S3Link should manage</param> /// <param name="key">The key that S3Link should store and download from</param> /// <param name="region">The region of the S3 resource</param> /// <returns>A new S3Link object that can upload and download to the target bucket</returns> public static S3Link Create(DynamoDBContext context, string bucket, string key, Amazon.RegionEndpoint region) { S3ClientCache cacheFromKey; if (S3Link.Caches.TryGetValue(context, out cacheFromKey)) { return(new S3Link(cacheFromKey, bucket, key, region.SystemName)); } var client = ((AmazonDynamoDBClient)context.Client); S3ClientCache cache = new S3ClientCache(client.GetCredentials(), client.CloneConfig <AmazonS3Config>()); lock (S3Link.cacheLock) { S3Link.Caches.Add(context, cache); } return(new S3Link(cache, bucket, key, region.SystemName)); }
internal S3Link(S3ClientCache clientCache, string bucketName, string key, string region) : this(clientCache, new LinkInfo(bucketName, key, region)) { }
internal static S3ClientCache CreatClientCacheFromContext(DynamoDBContext context) { var client = ((AmazonDynamoDBClient)context.Client); var cache = new S3ClientCache(client.Credentials, client.CloneConfig<AmazonS3Config>()); lock (S3Link.cacheLock) { S3Link.Caches[context] = cache; } return cache; }
internal S3Link(S3ClientCache clientCache, string json) { if (clientCache == null) throw new ArgumentNullException("clientCache"); if (json == null) throw new ArgumentNullException("json"); this.s3ClientCache = clientCache; linker = JsonMapper.ToObject<LinkInfo>(json); }
private S3Link(S3ClientCache clientCache, LinkInfo linker) { if (linker == null) throw new ArgumentNullException("linker"); if (clientCache == null) throw new ArgumentNullException("clientCache"); this.s3ClientCache = clientCache; this.linker = linker; }