Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kevin Gonzales 5 posts 75 karma points
    Jun 26, 2023 @ 00:58
    Kevin Gonzales
    0

    Bulk Media Upload Exceptions when running the code

    I have a MediaBulkUpload.cs and Program.cs

    For Program.cs, I'm encountering this exception upon running the code

    System.InvalidOperationException: 'Unable to resolve service for type 'Umbraco.Cms.Core.Scoping.ICoreScopeProvider while attempting to activate Umbraco.Cms.Core.Service.MediaService

            var services = new ServiceCollection();
    
            // Register the Umbraco services
            services.AddSingleton<IMediaService, MediaService>();
            services.AddSingleton<IFileSystem, PhysicalFileSystem>();
    
            // Additional service registrations for Umbraco
            // ...
    
            // Build the service provider
            var serviceProvider = services.BuildServiceProvider();
    
            // Resolve an instance of MediaService
            var mediaService = serviceProvider.GetService<IMediaService>();
    
            // Create an instance of MediaBulkUpload and pass the required dependencies
            var bulkUpload = new MediaBulkUpload(mediaService);
    
            // Specify the folder path to perform bulk upload
            string folderPath = "TESTFOLDER";
    
            // Call the BulkUploadMedia method
            bulkUpload.BulkUploadMedia(folderPath);
    
            // Keep the console window open
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
    

    For context, I'm have a locally hosted Umbraco 11 running on CMD.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies