Skip to content

Commit df19a19

Browse files
Merge pull request #209 from andyfelton-equatedigital/feat/AWSProvider
Feat/aws AWS S3 provider
2 parents 9c0231e + aaf0b62 commit df19a19

30 files changed

Lines changed: 1128 additions & 120 deletions

.gitattributes

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,13 @@
8787
*.eot binary
8888
*.exe binary
8989
*.otf binary
90-
*.pbm binary
9190
*.pdf binary
9291
*.ppt binary
9392
*.pptx binary
9493
*.pvr binary
9594
*.snk binary
9695
*.ttc binary
9796
*.ttf binary
98-
*.wbmp binary
9997
*.woff binary
10098
*.woff2 binary
10199
*.xls binary
@@ -126,3 +124,10 @@
126124
*.dds filter=lfs diff=lfs merge=lfs -text
127125
*.ktx filter=lfs diff=lfs merge=lfs -text
128126
*.ktx2 filter=lfs diff=lfs merge=lfs -text
127+
*.pam filter=lfs diff=lfs merge=lfs -text
128+
*.pbm filter=lfs diff=lfs merge=lfs -text
129+
*.pgm filter=lfs diff=lfs merge=lfs -text
130+
*.ppm filter=lfs diff=lfs merge=lfs -text
131+
*.pnm filter=lfs diff=lfs merge=lfs -text
132+
*.wbmp filter=lfs diff=lfs merge=lfs -text
133+
*.exr filter=lfs diff=lfs merge=lfs -text

.github/workflows/build-and-test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ jobs:
7777
npm install -g azurite
7878
azurite --loose &
7979
80+
- name: Setup s3rver
81+
if: matrix.options.os != 'windows-latest'
82+
shell: bash
83+
run: |
84+
sudo npm install -g s3rver
85+
sudo s3rver -d . &
86+
87+
- name: Setup s3rver Windows
88+
if: matrix.options.os == 'windows-latest'
89+
shell: bash
90+
run: |
91+
npm install -g s3rver
92+
s3rver -d . &
93+
8094
- name: Setup NuGet Cache
8195
uses: actions/cache@v2
8296
id: nuget-cache

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ publish/
134134
# Publish Web Output
135135
*.[Pp]ublish.xml
136136
*.azurePubxml
137-
# TODO: Comment the next line if you want to checkin your web deploy settings
137+
# TODO: Comment the next line if you want to checkin your web deploy settings
138138
# but database connection strings (with potential passwords) will be unencrypted
139139
*.pubxml
140140
*.publishproj
@@ -214,7 +214,7 @@ artifacts/
214214
*.csproj.bak
215215

216216
#CodeCoverage
217-
*.lcov
217+
*.lcov
218218

219219
**/is-cache/
220220

ImageSharp.Web.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Web.Benchmarks",
4040
EndProject
4141
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Web.Providers.Azure", "src\ImageSharp.Web.Providers.Azure\ImageSharp.Web.Providers.Azure.csproj", "{E2A545EC-B909-4EAD-B95F-397F68588BE3}"
4242
EndProject
43+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Web.Providers.AWS", "src\ImageSharp.Web.Providers.AWS\ImageSharp.Web.Providers.AWS.csproj", "{E631D300-ACD5-40EA-A6BB-08E22092EC76}"
44+
EndProject
4345
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{B8152C86-B657-4967-B297-42F89A10D23A}"
4446
EndProject
4547
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SharedInfrastructure", "shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.shproj", "{68A8CC40-6AED-4E96-B524-31B1158FDEEA}"
@@ -69,6 +71,7 @@ Global
6971
shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems*{2f1b36e2-5d92-4442-b816-d2a978246435}*SharedItemsImports = 5
7072
shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems*{68a8cc40-6aed-4e96-b524-31b1158fdeea}*SharedItemsImports = 13
7173
shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems*{e2a545ec-b909-4ead-b95f-397f68588be3}*SharedItemsImports = 5
74+
shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems*{e631d300-acd5-40ea-a6bb-08e22092ec76}*SharedItemsImports = 5
7275
EndGlobalSection
7376
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7477
Debug|Any CPU = Debug|Any CPU
@@ -127,6 +130,18 @@ Global
127130
{E2A545EC-B909-4EAD-B95F-397F68588BE3}.Release|x64.Build.0 = Release|Any CPU
128131
{E2A545EC-B909-4EAD-B95F-397F68588BE3}.Release|x86.ActiveCfg = Release|Any CPU
129132
{E2A545EC-B909-4EAD-B95F-397F68588BE3}.Release|x86.Build.0 = Release|Any CPU
133+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
134+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Debug|Any CPU.Build.0 = Debug|Any CPU
135+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Debug|x64.ActiveCfg = Debug|Any CPU
136+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Debug|x64.Build.0 = Debug|Any CPU
137+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Debug|x86.ActiveCfg = Debug|Any CPU
138+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Debug|x86.Build.0 = Debug|Any CPU
139+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Release|Any CPU.ActiveCfg = Release|Any CPU
140+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Release|Any CPU.Build.0 = Release|Any CPU
141+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Release|x64.ActiveCfg = Release|Any CPU
142+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Release|x64.Build.0 = Release|Any CPU
143+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Release|x86.ActiveCfg = Release|Any CPU
144+
{E631D300-ACD5-40EA-A6BB-08E22092EC76}.Release|x86.Build.0 = Release|Any CPU
130145
{8F40DEC6-A97F-4002-A504-13E188665A98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
131146
{8F40DEC6-A97F-4002-A504-13E188665A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
132147
{8F40DEC6-A97F-4002-A504-13E188665A98}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -148,6 +163,7 @@ Global
148163
{8864C96C-94AA-454D-BAF5-779216C3745A} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
149164
{0B15E490-7821-42DF-86A5-4DEAE921DE59} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
150165
{E2A545EC-B909-4EAD-B95F-397F68588BE3} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
166+
{E631D300-ACD5-40EA-A6BB-08E22092EC76} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
151167
{B8152C86-B657-4967-B297-42F89A10D23A} = {C317F1B1-D75E-4C6D-83EB-80367343E0D7}
152168
{68A8CC40-6AED-4E96-B524-31B1158FDEEA} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
153169
{04955CD1-F249-4899-9F61-6C7487BEECE1} = {B8152C86-B657-4967-B297-42F89A10D23A}

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,26 @@ git submodule update --init --recursive
8686

8787
#### Running the Tests
8888

89-
The unit tests require [Azurite Azure Storage Emulator](https://github.com/Azure/Azurite) in order to run.
89+
The unit tests require [Azurite Azure Storage Emulator](https://github.com/Azure/Azurite) and [s3rver](https://github.com/jamhall/s3rver) in order to run.
9090

9191
On Windows to install and run the server as a background process run the following command
9292

9393
```bash
9494
npm install -g azurite
9595
start /B azurite --loose
96+
97+
npm install -g s3rver
98+
start /B s3rver -d .
9699
```
97100

98101
On Linux
99102

100103
```bash
101104
sudo npm install -g azurite
102105
sudo azurite --loose &
106+
107+
sudo npm install -g s3rver
108+
sudo s3rver -d . &
103109
```
104110

105111
## How can you help?
@@ -112,4 +118,4 @@ Please... Spread the word, contribute algorithms, submit performance improvement
112118
- [Dirk Lemstra](https://github.com/dlemstra)
113119
- [Anton Firsov](https://github.com/antonfirsov)
114120
- [Scott Williams](https://github.com/tocsoft)
115-
- [Brian Popow](https://github.com/brianpopow)
121+
- [Brian Popow](https://github.com/brianpopow)

codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ codecov:
99
# Avoid Report Expired
1010
# https://docs.codecov.io/docs/codecov-yaml#section-expired-reports
1111
max_report_age: off
12+
13+
coverage:
14+
# Use integer precision
15+
# https://docs.codecov.com/docs/codecovyml-reference#coverageprecision
16+
precision: 0
17+
18+
# Explicitly control coverage status checks
19+
# https://docs.codecov.com/docs/commit-status#disabling-a-status
20+
status:
21+
project: on
22+
patch: off
-24.5 KB
Loading

src/Directory.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" />
1818

1919
<ItemGroup>
20+
<PackageReference Update="AWSSDK.S3" Version="3.7.7.16" />
2021
<PackageReference Update="Azure.Storage.Blobs" Version="12.10.0" />
2122
<PackageReference Update="Microsoft.IO.RecyclableMemoryStream" Version="2.2.0" />
2223
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System;
5+
using Amazon;
6+
using Amazon.S3;
7+
using SixLabors.ImageSharp.Web.Providers.AWS;
8+
9+
namespace SixLabors.ImageSharp.Web
10+
{
11+
internal static class AmazonS3ClientFactory
12+
{
13+
/// <summary>
14+
/// Creates a new bucket under the specified account if a bucket
15+
/// with the same name does not already exist.
16+
/// </summary>
17+
/// <param name="options">The AWS S3 Storage cache options.</param>
18+
/// <returns>
19+
/// A new <see cref="AmazonS3Client"/>.
20+
/// </returns>
21+
public static AmazonS3Client CreateClient(AWSS3BucketClientOptions options)
22+
{
23+
if (!string.IsNullOrWhiteSpace(options.Endpoint))
24+
{
25+
// AccessKey can be empty.
26+
// AccessSecret can be empty.
27+
AmazonS3Config config = new() { ServiceURL = options.Endpoint, ForcePathStyle = true };
28+
return new AmazonS3Client(options.AccessKey, options.AccessSecret, config);
29+
}
30+
else if (!string.IsNullOrWhiteSpace(options.AccessKey))
31+
{
32+
// AccessSecret can be empty.
33+
Guard.NotNullOrWhiteSpace(options.Region, nameof(options.Region));
34+
var region = RegionEndpoint.GetBySystemName(options.Region);
35+
return new AmazonS3Client(options.AccessKey, options.AccessSecret, region);
36+
}
37+
else if (!string.IsNullOrWhiteSpace(options.Region))
38+
{
39+
var region = RegionEndpoint.GetBySystemName(options.Region);
40+
return new AmazonS3Client(region);
41+
}
42+
else
43+
{
44+
throw new ArgumentException("Invalid configuration.", nameof(options));
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)