error when extacting container name from path in Azure Blob Store provider
63Digital opened this issue ยท 7 comments
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp.Web
- I have verified if the problem exist in both
DEBUG
andRELEASE
mode - I have searched open and closed issues to ensure it has not already been reported
Description
I'm using RC-1 with the azure blob store provider and getting a 404 on any images stored on Azure (local images work fine). I think the issue lines on line 92 of AzureBlobStorageImageProvider.cs.
When extracting the container key from the URL, instead of
string nameToMatch = index != -1 ? path.Substring(index) : path;
should it not be
string nameToMatch = index != -1 ? path.Substring(0 ,index) : path;
to extract the first portion of the path?
I've copied the code for the Azure provider directly into my project and made the above change and it's resolved my issue so i'm reasonably confident in the above.
Steps to Reproduce
Attempt to resize an image stored on an Azure blob
System Configuration
- ImageSharp.Web version: RC-1
- Other ImageSharp packages and versions:
- Environment (Operating system, version and so on): Windows 10
- .NET Framework version: dotnet core 3.1
- Additional information:
Hey @63Digital Can you please share a URL and your configuration please (minus keys of course). I'd like to know how this slipped through unit tests.
`
services.AddImageSharpCore()
.SetRequestParser<QueryCollectionRequestParser>()
.Configure<PhysicalFileSystemCacheOptions>(_ => { _.CacheFolder = Configuration.GetValue<string>("ImageCachePath"); })
.SetCache<PhysicalFileSystemCache>()
.SetCacheHash<CacheHash>()
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = Configuration.GetConnectionString("AzureBlobConnection"),
ContainerName = Configuration.GetSection("AzureBlobContainerName").Value
});
})
.AddProvider<AzureBlobStorageImageProvider>()
.AddProvider<PhysicalFileSystemProvider>()
.AddProcessor<ResizeWebProcessor>();
`
Connection String
DefaultEndpointsProtocol=https;AccountName=aquaitsupport;AccountKey=*** Account Key ***;EndpointSuffix=core.windows.net
Container Name: web
Sample URL: https://localhost:44319/web/63digital/5062862f-ab55-49ec-a187-e13afe00790e.png?width=50
Sorry, don't have it live anywhere yet
Thanks, I'll investigate and get a a fix out ASAP.
Fixed package released. See
https://www.nuget.org/packages/SixLabors.ImageSharp.Web.Providers.Azure/1.0.0-rc0002
Thanks for your help!
Not sure if it's related, but I am also getting a 404 for images in Azure Blob Store. I am on the latest version 1.0.3.
I've got a couple of projects running the latest Azure provider with no issues, I don't think this issue has regressed?
I found discussions #170 and the solution was to clear the providers. After adding the below ClearProviders method it started to work.
.ClearProviders()
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
// The "BlobContainers" collection allows registration of multiple containers.
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = {AZURE_CONNECTION_STRING},
ContainerName = {AZURE_CONTAINER_NAME}
});
})
.AddProvider<AzureBlobStorageImageProvider>()