Hi again,
It looks that I found a root cause. Decided to check the example (https://github.com/SixLabors/ImageSharp.Web/blob/main/samples/ImageSharp.Web.Sample/Startup.cs) one more time and found that I have a wrong position of image processing middleware.
So, final version of Configure method is:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
/* geta-notfoundhandler begin */
app.UseNotFoundHandler();
/* geta-notfoundhandler end */
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
// Add the image processing middleware.
app.UseBaaijteOptimizelyImageSharp();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapContent();
endpoints.MapControllers();
endpoints.MapRazorPages(); /* required for "geta-notfoundhandler" as well */
});
}
Hi Maxim,
I tried same approach but getting error on DXP.
Do you have any suggestion how to fix it? - Thanks!
See complete log.
2022-09-01T06:01:08.169154963Z System.IO.DirectoryNotFoundException: Could not find a part of the path '/app/App_Data/blobs/b9cd4e8815db4dc081fd1fd8bdecd642/77aa03178c234b9fbec92d99e293280b.png'.
2022-09-01T06:01:08.169159863Z at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
2022-09-01T06:01:08.169165163Z at Interop.CheckIo(Error error, String path, Boolean isDirectory, Func`2 errorRewriter)
2022-09-01T06:01:08.169170463Z at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
2022-09-01T06:01:08.169175363Z at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
2022-09-01T06:01:08.169181063Z at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
2022-09-01T06:01:08.169187063Z at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
2022-09-01T06:01:08.169209764Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
2022-09-01T06:01:08.169214864Z at EPiServer.Framework.Blobs.FileBlob.OpenRead()
2022-09-01T06:01:08.169219364Z at EPiServer.Framework.Blobs.BlobExtensions.ReadAllBytes(Blob blob)
2022-09-01T06:01:08.169223964Z at EPiServer.Cms.Shell.UI.Controllers.Internal.ThumbnailController.Generate(ContentReference contentLink)
2022-09-01T06:01:08.169228464Z at lambda_method893(Closure , Object , Object[] )
2022-09-01T06:01:08.169574768Z at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
2022-09-01T06:01:08.169591468Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
2022-09-01T06:01:08.169617668Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2022-09-01T06:01:08.169625169Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
2022-09-01T06:01:08.169630769Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2022-09-01T06:01:08.169636769Z at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
2022-09-01T06:01:08.169641869Z --- End of stack trace from previous location ---
2022-09-01T06:01:08.169646069Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
2022-09-01T06:01:08.169650969Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
2022-09-01T06:01:08.169655269Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
2022-09-01T06:01:08.169660169Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
2022-09-01T06:01:08.169664669Z --- End of stack trace from previous location ---
2022-09-01T06:01:08.169669069Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
2022-09-01T06:01:08.169673469Z at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
2022-09-01T06:01:08.169677869Z at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
2022-09-01T06:01:08.169682669Z at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
2022-09-01T06:01:08.169700669Z at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
2022-09-01T06:01:08.169707170Z at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
2022-09-01T06:01:08.169713670Z at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
2022-09-01T06:01:08.169719170Z at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
2022-09-01T06:01:08.169725070Z at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
2022-09-01T06:01:08.169730370Z at EPiServer.Middleware.InitializeOnFirstRequestMiddleware.InvokeAsync(HttpContext httpContext)
2022-09-01T06:01:08.169735770Z at EPiServer.Framework.DependencyInjection.Internal.VisitorGroupMiddleware.Invoke(HttpContext httpContext)
2022-09-01T06:01:08.169741170Z at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
One thing we found was that in addition to adding the app.UseBaaijteOptimizelyImageSharp(); middleware early in the Configure() method, we also had to add services.AddBaaijteOptimizelyImageSharp(); before configuring the blob and caching provider options in the ConfigureServices() method.
Hi @Daniel
I tried same way, here is the code sample but no luck.
public void ConfigureServices(IServiceCollection services)
{
services.AddBaaijteOptimizelyImageSharp();
if (!_webHostingEnvironment.IsDevelopment())
{
services.AddCmsCloudPlatformSupport(_configuration);
}
services.AddMvc();
services.AddSite();
services.AddCms();
services.AddImagePointEditor();
services.AddEmbeddedLocalization<Startup>();
services.Configure<AppSettings>(_configuration.GetSection("AppSettings"));
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseBaaijteOptimizelyImageSharp();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseSession();
}
Hi Sanjay. You need have slightly different config when running on you local machine (storing the blobs in the file system) compared to when running in Azure (storing the blobs in Azure storage).
Take a look at the config needed for DXP here: https://github.com/vnbaaij/Baaijte.Optimizely.ImageSharp.Web#configuration-for-use-with-dxp
In the example code for DXP the connection string is being read from the connectionStrings section. However, the connection string for the Azure provider is no where to be found for DXP since it is hidden inside Azure Vaults. Is there any way to reveal it?
.Configure<AzureBlobStorageCacheOptions>(options =>
{
options.ConnectionString = _configuration.GetConnectionString("EPiServerAzureBlobs");
options.ContainerName = "mysitemedia";
})
Hi,
I have tried Baaijte.Optimizely.ImageSharp.Web on my current project, image resizing works perfectly fine when view on website, but I noticed images are not resized when in edit/preview mode, can anyone have any solution for this?
Thanks in Advance!
Hi,
Thanks for the quick reply!
Please ignore the above screen shot, here is the updated one.
Hi,
Short info: CMS 12.3, DXP is used (tested on "Integration" only for now), Azure Blob storage is configured.
I am trying to configure PictureRenderer.Optimizely in order to generate <picture> elements. The html looks good, but the image is not resized.
Example of html:
As I understand the relations of the modules is the following one:
My dependencies:
Part of ConfigureServices method.
My Configure method (only the last row in the method is related to this task).
I looked through example: https://github.com/SixLabors/ImageSharp.Web/blob/main/samples/ImageSharp.Web.Sample/Startup.cs
and tried to add ".AddProcessor<ResizeWebProcessor>()" explicitly, but it didn't help.
It is worth to mention that readme file for module Baaijte.Optimizely.ImageSharp.Web contains statement : DO NOT add other
SixLabors.ImageSharp.Web
settings!!So, I haven't tried to use any other options...
Will be glad to know if somebody uses the same modules and has a working configuration. Thank you in advance.
Best regards,
Maxim