How did you setup the FileBlobProvider?
E.g.
{
"EPiServer":{
"Cms":{
"BlobProvidersOptions": {
"DefaultProvider": "fileShare",
"Providers": {
"fileShare": "EPiServer.Framework.Blobs.FileBlobProvider, EPiServer.Framework"
},
},
"FileBlobProvider": {
"Path": "\\\\myserver\\optidata"
}
}
}
}
Have you ensured you have enabled the serving of static files
app.UseStaticFiles();
The blob provider is added with services.AddFileBlobProvider("fileShare", configuration.EpiserverBlobPath);
where the configured blob path indeed exists. Obviously is picked up, since uploads put new files in the correct place (Updated original post with this now.)
UseStaticFiles()
is also called. May it be the order in which this is placed? If so, where should it be, set up against all the other must-haves?
I noticed something now:
Part of our config is this:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapEPiServerExtensionEndpoints();
});
If I replace the MapEPiServerExtensionEndpoints() with MapContent(), the images work, but it shuts down our own controllers (with System.ArgumentNullException: Value cannot be null. (Parameter 'key')
).
This whole code base is not using any razor pages; it's purely a content API with custom controllers (with route attributes), so we don't need any default routing or anything from the CMS, except for media files. Are there other alternatives here that would help? A lot of the stuff inside MapContent()
is internal, so I can't add it myself...
Which version of CMS12 are you running?
Are you using minimal api:s or regular web api:s?
I typically add specific endpoints registrations for API:s in CMS12.
public static class ServiceCollectionExtensions
{
internal const string ApiRoute = "/api/myapi";
public static IEndpointRouteBuilder MyApiEndpoint(this IEndpointRouteBuilder builder)
{
builder.MapGet(ApiRoute, (MyApiRequest request, IMyApiService service) =>
{
var response = service.GetMyStuff(request.whaterver, request.somethingelse);
return Microsoft.AspNetCore.Http.Results.Json(response, new System.Text.Json.JsonSerializerOptions() { PropertyNamingPolicy = null });
});
return builder;
}
}
// in startup
app.UseEndpoints(endpoints =>
{
endpoints.MyApiEndpoint();
endpoints.MapContent();
// ...
});
Version: 12.19.0 - so pretty much up to date.
Regular oldschool Controllers with [Route("...")]
scattered around. It's not an option to rewrite this into flat MapGet(...)
as you showed here... :-\
It seems very strange to me though, that such a standard thing is so....obscure? Having some pure API-controllers on the side of page controllers must be something every project has, no?
Seems like the issue was some custom template resolution on our side, that basically selects an empty object. So, if fiddling about with the ITemplateResolver.TemplateResolving
event, beware.
In addition, a basic, empty content controller was required too. If not, everything just returns empty responses. For some reason. 🤷
public class RootContentController : ContentController<PageData>
{
public ActionResult Index(PageData currentPage)
{
return Content("Hello world!");
}
}
Ahoy.
We've recently upgraded to CMS 12, and now, all our media files are returning 404 to visitors.
Any pointers?