I am creating an implementation using MediaSavedNotification, in which I need to process the information of a CSV file, which has thousands of records and I am using this interface IBackgroundTaskQueue But I get the following notification Authorization error: Unauthorized access to URL: /umbraco/backoffice/umbracoapi/media/PostSave Contact your administrator for information.
The whole process works correctly in the background service.
When implementing the non-background processing, this works correctly, but the Media Library stays busy until it finishes processing the whole file.
My code is below
public class MediaSavedNotificationHandler(IBackgroundTaskQueue queue, IServiceProvider serviceProvider)
: INotificationAsyncHandler<MediaSavedNotification>
{
public async Task HandleAsync(MediaSavedNotification notification, CancellationToken cancellationToken)
{
var mediaItems = notification.SavedEntities;
foreach (var mediaItem in mediaItems)
{
if (mediaItem.Key == MediaNodeIdIdentifiers.MaintenanceProvidersFileNodeId)
{
queue.QueueBackgroundWorkItem(async cancellationToken =>
{
using IServiceScope scope = serviceProvider.CreateScope();
var maintenanceProviderService = scope.ServiceProvider.GetRequiredService<IMaintenanceProviderService>();
await maintenanceProviderService.ImportProviders(mediaItem.Id);
});
notification.Messages.Add(new EventMessage("Maintenance Provider Notification",
"The Maintenance Providers import process has started and is running in the background.",
EventMessageType.Info));
return;
}
}
}
}
INotificationAsyncHandler and BackgroundTaskQueue
I am creating an implementation using MediaSavedNotification, in which I need to process the information of a CSV file, which has thousands of records and I am using this interface IBackgroundTaskQueue But I get the following notification Authorization error: Unauthorized access to URL: /umbraco/backoffice/umbracoapi/media/PostSave Contact your administrator for information. The whole process works correctly in the background service. When implementing the non-background processing, this works correctly, but the Media Library stays busy until it finishes processing the whole file. My code is below
is working on a reply...