11using Amazon . S3 ;
22using Amazon . S3 . Model ;
33using ImageWizard . Core ;
4- using ImageWizard . Core . ImageLoaders ;
5- using ImageWizard . Core . Types ;
6- using ImageWizard . Services . Types ;
4+ using ImageWizard . Loaders ;
75using Microsoft . Extensions . Options ;
86using System ;
97using System . Collections . Generic ;
@@ -16,20 +14,14 @@ namespace ImageWizard.AWS
1614 /// <summary>
1715 /// AwsLoader
1816 /// </summary>
19- public class AwsLoader : DataLoaderBase
17+ public class AwsLoader : DataLoaderBase < AwsOptions >
2018 {
2119 public AwsLoader ( IOptions < AwsOptions > options )
20+ : base ( options )
2221 {
23- Options = options . Value ;
24-
25- Client = new AmazonS3Client ( Options . AccessKeyId , Options . SecretAccessKey ) ;
22+ Client = new AmazonS3Client ( Options . Value . AccessKeyId , Options . Value . SecretAccessKey ) ;
2623 }
2724
28- /// <summary>
29- /// Options
30- /// </summary>
31- public AwsOptions Options { get ; }
32-
3325 /// <summary>
3426 /// Client
3527 /// </summary>
@@ -39,7 +31,7 @@ public override async Task<OriginalData> GetAsync(string source, ICachedData exi
3931 {
4032 GetObjectRequest request = new GetObjectRequest ( )
4133 {
42- BucketName = Options . BucketName ,
34+ BucketName = Options . Value . BucketName ,
4335 Key = source
4436 } ;
4537
@@ -50,16 +42,14 @@ public override async Task<OriginalData> GetAsync(string source, ICachedData exi
5042
5143 GetObjectResponse result = await Client . GetObjectAsync ( request ) ;
5244
53- if ( result . HttpStatusCode == System . Net . HttpStatusCode . NotModified )
45+ if ( result . HttpStatusCode == System . Net . HttpStatusCode . NotModified )
5446 {
5547 return null ;
5648 }
5749
58- byte [ ] data = await result . ResponseStream . ToByteArrayAsync ( ) ;
59-
6050 return new OriginalData (
6151 result . Headers . ContentType ,
62- await result . ResponseStream . ToByteArrayAsync ( ) ,
52+ result . ResponseStream ,
6353 new CacheSettings ( ) { ETag = result . ETag . GetTagUnquoted ( ) } ) ;
6454 }
6555 }
0 commit comments