Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ jobs:
shell: bash
run: |
sudo npm install -g azurite
sudo azurite --loose &
sudo azurite --loose --skipApiVersionCheck &

- name: Azurite Setup Windows
if: matrix.options.os == 'windows-latest'
shell: bash
run: |
npm install -g azurite
azurite --loose &
azurite --loose --skipApiVersionCheck &

- name: S3rver Setup
if: matrix.options.os != 'windows-latest'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ On Windows to install and run the server as a background process run the followi

```bash
npm install -g azurite
start /B azurite --loose
start /B azurite --loose --skipApiVersionCheck

npm install -g s3rver
start /B s3rver -d .
Expand All @@ -100,7 +100,7 @@ On Linux

```bash
sudo npm install -g azurite
sudo azurite --loose &
sudo azurite --loose --skipApiVersionCheck &

sudo npm install -g s3rver
sudo s3rver -d . &
Expand Down
7 changes: 4 additions & 3 deletions src/ImageSharp.Web.Providers.AWS/Caching/AWSS3StorageCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public Task SetAsync(string key, Stream stream, ImageCacheMetadata metadata)
Key = this.GetKeyWithFolder(key),
ContentType = metadata.ContentType,
InputStream = stream,
AutoCloseStream = false
AutoCloseStream = false,
UseChunkEncoding = false
};

foreach (KeyValuePair<string, string> d in metadata.ToDictionary())
Expand Down Expand Up @@ -141,7 +142,7 @@ private static readonly TaskFactory TaskFactory
/// <summary>
/// Executes an async <see cref="Task"/> method synchronously.
/// </summary>
/// <param name="task">The task to excecute.</param>
/// <param name="task">The task to execute.</param>
public static void RunSync(Func<Task> task)
{
CultureInfo cultureUi = CultureInfo.CurrentUICulture;
Expand All @@ -159,7 +160,7 @@ public static void RunSync(Func<Task> task)
/// a <paramref name="task"/> return type synchronously.
/// </summary>
/// <typeparam name="TResult">The type of result to return.</typeparam>
/// <param name="task">The task to excecute.</param>
/// <param name="task">The task to execute.</param>
/// <returns>The <typeparamref name="TResult"/>.</returns>
public static TResult RunSync<TResult>(Func<Task<TResult>> task)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.7.103.42" />
<PackageReference Include="AWSSDK.S3" Version="4.0.6.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Task<ImageCacheMetadata> GetMetaDataAsync()
foreach (string key in this.metadata.Keys)
{
// Trim automatically added x-amz-meta-
dict.Add(key.Substring(11).ToUpperInvariant(), this.metadata[key]);
dict.Add(key[11..].ToUpperInvariant(), this.metadata[key]);
}

return Task.FromResult(ImageCacheMetadata.FromDictionary(dict));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ public async Task<ImageMetadata> GetMetaDataAsync()
}
}

return new ImageMetadata(metadata.LastModified, maxAge, metadata.ContentLength);
return new ImageMetadata(metadata.LastModified ?? DateTime.UtcNow, maxAge, metadata.ContentLength);
}

/// <inheritdoc />
public Task<Stream> OpenReadAsync() => this.amazonS3.GetObjectStreamAsync(this.bucketName, this.imagePath, null);
public Task<Stream> OpenReadAsync()
=> this.amazonS3.GetObjectStreamAsync(this.bucketName, this.imagePath, null);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>SixLabors.ImageSharp.Web.Providers.Azure</AssemblyName>
Expand Down Expand Up @@ -43,7 +43,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.15.1" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.25.0" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions src/ImageSharp.Web/Middleware/ImageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public ImageContext(HttpContext context, ImageSharpMiddlewareOptions options)
internal enum PreconditionState
{
/// <summary>
/// Unspeciified
/// Unspecified
/// </summary>
Unspecified,

Expand All @@ -88,7 +88,7 @@ internal enum PreconditionState
/// The combined components of the image request URL in a fully un-escaped form (except
/// for the QueryString) suitable only for display.
/// </returns>
public string GetDisplayUrl() => this.request.GetDisplayUrl();
public readonly string GetDisplayUrl() => this.request.GetDisplayUrl();

/// <summary>
/// Analyzes the headers for the current request.
Expand All @@ -110,7 +110,7 @@ public void ComprehendRequestHeaders(DateTimeOffset lastModified, long length)
/// Gets the preconditioned state of the request.
/// </summary>
/// <returns>The <see cref="PreconditionState"/>.</returns>
public PreconditionState GetPreconditionState()
public readonly PreconditionState GetPreconditionState()
=> GetMaxPreconditionState(
this.ifMatchState,
this.ifNoneMatchState,
Expand All @@ -121,7 +121,7 @@ public PreconditionState GetPreconditionState()
/// Gets a value indicating whether this request is a head request.
/// </summary>
/// <returns>THe <see cref="bool"/>.</returns>
public bool IsHeadRequest()
public readonly bool IsHeadRequest()
=> string.Equals("HEAD", this.request.Method, StringComparison.OrdinalIgnoreCase);

/// <summary>
Expand All @@ -130,7 +130,7 @@ public bool IsHeadRequest()
/// <param name="statusCode">The status code.</param>
/// <param name="metaData">The image metadata.</param>
/// <returns>The <see cref="Task"/>.</returns>
public Task SendStatusAsync(int statusCode, in ImageCacheMetadata metaData)
public readonly Task SendStatusAsync(int statusCode, in ImageCacheMetadata metaData)
=> this.ApplyResponseHeadersAsync(
statusCode,
metaData.ContentType,
Expand All @@ -142,7 +142,7 @@ public Task SendStatusAsync(int statusCode, in ImageCacheMetadata metaData)
/// <param name="stream">The output stream.</param>
/// <param name="metaData">The image metadata.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task SendAsync(Stream stream, ImageCacheMetadata metaData)
public readonly async Task SendAsync(Stream stream, ImageCacheMetadata metaData)
{
await this.ApplyResponseHeadersAsync(
ResponseConstants.Status200Ok,
Expand Down Expand Up @@ -176,7 +176,7 @@ private static PreconditionState GetMaxPreconditionState(params PreconditionStat
return max;
}

private async Task ApplyResponseHeadersAsync(
private readonly async Task ApplyResponseHeadersAsync(
int statusCode,
string contentType,
TimeSpan maxAge)
Expand Down
2 changes: 1 addition & 1 deletion src/ImageSharp.Web/Middleware/ResponseConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace SixLabors.ImageSharp.Web.Middleware;

/// <summary>
/// Contains constants related to HTTP respose codes.
/// Contains constants related to HTTP response codes.
/// </summary>
internal static class ResponseConstants
{
Expand Down
3 changes: 3 additions & 0 deletions src/ImageSharp.Web/Providers/PhysicalFileSystemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public PhysicalFileSystemProvider(
/// <param name="webRootPath">The web root path.</param>
/// <param name="contentRootPath">The content root path.</param>
/// <returns><see cref="string"/> representing the fully qualified provider root path.</returns>
/// <exception cref="InvalidOperationException">
/// Thrown when the provider root path cannot be determined.
/// </exception>
internal static string GetProviderRoot(PhysicalFileSystemProviderOptions options, string webRootPath, string contentRootPath)
{
string providerRootPath = options.ProviderRootPath ?? webRootPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static async Task InitializeAWSStorageAsync(IServiceProvider services, A
catch
{
IFileInfo file = environment.WebRootFileProvider.GetFileInfo(TestConstants.ImagePath);
using Stream stream = file.CreateReadStream();
await using Stream stream = file.CreateReadStream();

// Set the max-age property so we get coverage for testing in our AWS provider.
CacheControlHeaderValue cacheControl = new()
Expand All @@ -100,7 +100,9 @@ private static async Task InitializeAWSStorageAsync(IServiceProvider services, A
CacheControl = cacheControl.ToString()
},
ContentType = " image/png",
InputStream = stream
InputStream = stream,
AutoCloseStream = false,
UseChunkEncoding = false,
};

await amazonS3Client.PutObjectAsync(putRequest);
Expand Down
12 changes: 7 additions & 5 deletions tests/ImageSharp.Web.Tests/TestUtilities/ServerTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ protected ServerTestBase(TFixture fixture, ITestOutputHelper outputHelper, strin
this.OutputHelper = outputHelper;
this.ImageSource = imageSource;

this.OutputHelper.WriteLine("EnvironmentalVariables");
foreach (DictionaryEntry item in Environment.GetEnvironmentVariables())
{
this.OutputHelper.WriteLine($"Key = {item.Key}, Value = {item.Value}");
}
this.OutputHelper.WriteLine(typeof(TFixture).Name);

//this.OutputHelper.WriteLine("EnvironmentalVariables");
//foreach (DictionaryEntry item in Environment.GetEnvironmentVariables())
//{
// this.OutputHelper.WriteLine($"Key = {item.Key}, Value = {item.Value}");
//}
}

public TFixture Fixture { get; }
Expand Down
Loading