我正在尝试使用 ImageSharp.web 使用 .net Core 进行图像处理。在使用存储在 wwwroot 中的图像进行测试后,该图像成功运行,我现在正在尝试处理存储在 Azure Blob 存储中的图像,但我没有成功,得到“服务器响应状态为 404 ()”(未找到)。
我遵循了 Sixlabors 教程,但无法在以下位置获得图像结果:
https://localhost:44344/X/foto-teste10515264.jpg -> X 是容器名称。
我在 startup.cs 中有以下配置:
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddImageSharp()
.SetRequestParser<QueryCollectionRequestParser>()
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
// The "BlobContainers" collection allows registration of multiple containers.
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = "DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;EndpointSuffix=core.windows.net",
ContainerName = "X"
});
})
.SetCache<PhysicalFileSystemCache>()
.SetCacheHash<CacheHash>()
.AddProvider<AzureBlobStorageImageProvider>()
.AddProcessor<ResizeWebProcessor>()
.AddProcessor<FormatWebProcessor>()
.AddProcessor<BackgroundColorWebProcessor>();
}
我的配置:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseImageSharp();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
我已经将 URL 更改为 https://localhost:5001/X/foto-teste10515264.jpg 现在我得到 net::ERR_CONNECTION_REFUSED