Open Closed

File Management implementation issues and questions #5072


User avatar
0
hinairusu created
  • ABP Framework version: v7.2.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Yes, Microservice Design

a) For File Management I have a couple of questions. The most important one being how do I remove this Unauthorised (I'm logged in as admin, and the UI says I have permissions) and why is it occuring? [2023-05-15T09:04:40.996Z] Error: Volo.Abp.Http.Client.AbpRemoteCallException: Unauthorized at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase 1.ThrowExceptionForResponseAsync(HttpResponseMessage response) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase 1.RequestAsync(ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase 1.RequestAsync[T](ClientProxyRequestContext requestContext) at Volo.Abp.Http.Client.ClientProxying.ClientProxyBase 1.RequestAsync[T](String methodName, ClientProxyRequestTypeValue arguments) at Volo.FileManagement.Directories.ClientProxies.DirectoryDescriptorClientProxy.GetContentAsync(DirectoryContentRequestInput input) at Volo.FileManagement.Blazor.Pages.FileManagement.FileManagement.GetDirectoryContentAsync() at Volo.FileManagement.Blazor.Pages.FileManagement.FileManagement.OnDirectoryContentDataGridReadAsync(DataGridReadDataEventArgs 1 e) at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Blazorise.DataGrid.DataGrid 1.HandleReadData(CancellationToken cancellationToken) at Blazorise.DataGrid.DataGrid 1.HandleReadData(CancellationToken cancellationToken) at Blazorise.DataGrid.DataGrid 1.Reload(CancellationToken cancellationToken) at Blazorise.DataGrid.DataGrid 1.OnAfterRenderAsync(Boolean firstRender) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

b) Secondly, when I implement FileManagementBlazorWebAssemblyModule as per the docs (using abp add-module Volo.FileManagement, https://docs.abp.io/en/commercial/latest/modules/file-management ) it returns a fault saying that there is not a singleton DB instance (This requirement isn't documented anywhere) but that's resolved by changing the implementation to FileManagementBlazorModule.

c) It's also worth highlighting that installing the file management module does not actually update the Ocelot.json etc, or use the namespace of the module it is installed into (which was another surprise for us)

d) Is it possible to restrict files so that only the person who has uploaded the file can see it? I don't have access to the source code, so I don't know what methods I can overwrite, or where I should be doing so to implement it if this is possible

e) Last question I have around File Management, Is there an example of the endpoints that the page calls so I can make other pages point at the upload, as the entire UI is hidden inside the Nuget. We would like to enable upload from a different page, and use the page the module provides for administrator users as it can see everything (or so it seems so far)


9 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    a)

    Please check the permissions of admin user. Please check the logs of api&authserver.

    b)

    it returns a fault

    Please share the details logs.

    c)

    I guess you need update it yourself. The suite can't handle the microservice very well.

    d)

    You can override the application services of FM module. See the API request on browser console.

    e)

    See the file uploda request on browser console.

    I suggest you consider upgrading your license to get the source code of the modules.

    : )

  • User Avatar
    0
    hinairusu created

    a)

    Please check the permissions of admin user. Please check the logs of api&authserver.

    b)

    it returns a fault

    Please share the details logs.

    c)

    I guess you need update it yourself. The suite can't handle the microservice very well.

    d)

    You can override the application services of FM module. See the API request on browser console.

    e)

    See the file uploda request on browser console.

    I suggest you consider upgrading your license to get the source code of the modules.

    : )

    a) Dropbox link for Auth Logs:https://www.dropbox.com/s/05epchpbe8cfhta/Auth-Server-Logs.txt?dl=0 Dropbox link for File Upload Logs: https://www.dropbox.com/s/5z70tgyme3kqmnn/File-Upload-Logs.txt?dl=0

    b) [blazor_d73061ee-6]: [16:12:49 FTL] DragonsHoard.Blazor terminated unexpectedly! [blazor_d73061ee-6]: Volo.Abp.AbpInitializationException: An error occurred during ConfigureServicesAsync phase of the module Volo.Abp.AspNetCore.Components.WebAssembly.AbpAspNetCoreComponentsWebAssemblyModule, Volo.Abp.AspNetCore.Components.WebAssembly, Version=7.2.1.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details. [blazor_d73061ee-6]: ---> System.InvalidOperationException: Could not find singleton service: Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder, Microsoft.AspNetCore.Components.WebAssembly, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 [blazor_d73061ee-6]: at Microsoft.Extensions.DependencyInjection.ServiceCollectionCommonExtensions.GetSingletonInstance[T](IServiceCollection services) [blazor_d73061ee-6]: at Microsoft.Extensions.DependencyInjection.AbpWebAssemblyServiceCollectionExtensions.GetHostBuilder(IServiceCollection services) [blazor_d73061ee-6]: at Volo.Abp.AspNetCore.Components.WebAssembly.AbpAspNetCoreComponentsWebAssemblyModule.ConfigureServices(ServiceConfigurationContext context) [blazor_d73061ee-6]: at Volo.Abp.Modularity.AbpModule.ConfigureServicesAsync(ServiceConfigurationContext context) [blazor_d73061ee-6]: at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync() [blazor_d73061ee-6]: --- End of inner exception stack trace --- [blazor_d73061ee-6]: at Volo.Abp.AbpApplicationBase.ConfigureServicesAsync() [blazor_d73061ee-6]: at Volo.Abp.AbpApplicationFactory.CreateAsync[TStartupModule](IServiceCollection services, Action 1 optionsAction) [blazor_d73061ee-6]: at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplicationAsync[TStartupModule](IServiceCollection services, Action 1 optionsAction) [blazor_d73061ee-6]: at Microsoft.Extensions.DependencyInjection.WebApplicationBuilderExtensions.AddApplicationAsync[TStartupModule](WebApplicationBuilder builder, Action 1 optionsAction) [blazor_d73061ee-6]: at DragonsHoard.Blazor.Program.Main(String[] args) in C:\Users\slink\source\repos\Nezuban\DragonsHoard\apps\blazor\src\DragonsHoard.Blazor\Program.cs:line 27

    c) I have updated the ocelot to include the file-management url's.

    d & e) Could I have a link to this please?

    While I'd love to upgrade to get access to the source code, and believe me it's pretty high on our priorites as we know how much not having it is hurting our ability to support ourselves on this, it's just not possible for our startup to get that sort of funding together. We pulled together for the individual commercial licence because we was hoping that the three modules we really needed would function out of the box. So far one has.

    We want to, Don't get me wrong. The additional developer seat alone would help us out immensely, but $6k is just way beyond us right now.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    a)

    Microsoft.IdentityModel.Tokens.SecurityTokenInvalidAudienceException: IDX10214: Audience validation failed. A Audiences: 'AccountService, IdentityService, AdministrationService, SaasService, ProductService, LibraryService'. Did not match: validationParameters.ValidAudience: 'FileUpload' or validationParameters.ValidAudiences: 'null'.

    Please change the audience base on the error message.

    b)

    An error occurred during ConfigureServicesAsync phase of the module Volo.Abp.AspNetCore.Components.WebAssembly.AbpAspNetCoreComponentsWebAssemblyModule, Volo.Abp.AspNetCore.Components.WebAssembly, Version=7.2.1.0, Culture=neutral, PublicKeyToken=null. See the inner exception for details. [ -6]: ---> System.InvalidOperationException: Could not find singleton service: Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHostBuilder, Microsoft.AspNetCore.Components.WebAssembly, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 [

    You need to call the AddApplicationAsync in your \blazor\src\DragonsHoard.Blazor\Program.cs:line 27

    https://github.com/abpframework/abp/blob/d01eb66c79c930c0d2436623905079f60559fae3/framework/src/Volo.Abp.AspNetCore.Components.WebAssembly/Microsoft/AspNetCore/Components/WebAssembly/Hosting/AbpWebAssemblyHostBuilderExtensions.cs#LL17C74-L17C93

    https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs#L12

    c) https://docs.abp.io/en/commercial/latest/startup-templates/microservice/add-microservice

    d & e)

    Could I have a link to this please?

    See the API request on the browser console when you upload files etc.

  • User Avatar
    0
    hinairusu created

    Thank you for the help so far, finally starting to make progress!

    I missed a line for the audience when implementing it, That's now been fixed and the page loads. However, after a few moments it throws a new error:

    [file-upload_f2322b15-f]: [10:51:08 ERR] An exception was thrown while activating Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext, Volo.FileManagement.EntityFrameworkCore, Version=7.2.2.0, Culture=neutral, PublicKeyToken=null]].
    [file-upload_f2322b15-f]: Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Volo.FileManagement.EntityFrameworkCore.FileManagementDbContext, Volo.FileManagement.EntityFrameworkCore, Version=7.2.2.0, Culture=neutral, PublicKeyToken=null]].
    [file-upload_f2322b15-f]: ---> Volo.Abp.AbpException: No configuration found for Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore, Version=7.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60! Use services.Configure<AbpDbContextOptions>(...) to configure it.
    [file-upload_f2322b15-f]: at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Configure[TDbContext](AbpDbContextOptions options, AbpDbContextConfigurationContext`1 context)
    

    I assume therefore that it is expecting a specific DB context, but it doesn't say anything about implementing that (https://docs.abp.io/en/commercial/latest/modules/file-management) But following the instructions I have the following:

    using Microsoft.EntityFrameworkCore;
    using Volo.Abp.Data;
    using Volo.Abp.EntityFrameworkCore;
    using Volo.FileManagement.EntityFrameworkCore;
    
    namespace DragonsHoard.FileUpload.EntityFrameworkCore;
    
    [ConnectionStringName(FileUploadDbProperties.ConnectionStringName)]
    public class FileUploadDbContext : AbpDbContext&lt;FileUploadDbContext&gt;
    {
    
        public FileUploadDbContext(DbContextOptions&lt;FileUploadDbContext&gt; options)
            : base(options)
        {
    
        }
    
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);
    
            builder.ConfigureFileUpload();
            builder.ConfigureFileManagement();
            }
    }
    
    

    Why isn't it using the context I have set up, and how do I repoint it to use the context I have? If I can't, do I need to set up a second context for the prebuilt?

    In case it becomes relevant at all / later I've got it set to push files to DB at the moment.

    public override void ConfigureServices(ServiceConfigurationContext context)
        {
            context.Services.AddAutoMapperObjectMapper&lt;FileUploadApplicationModule&gt;();
            Configure&lt;AbpAutoMapperOptions&gt;(options =>
            {
                options.AddMaps&lt;FileUploadApplicationModule&gt;(validate: true);
            });
            
            Configure&lt;AbpBlobStoringOptions&gt;(options =>
            {
                options.Containers.ConfigureDefault(c =>
                    c.UseDatabase());
                options.Containers.Configure&lt;FileManagementContainer&gt;(c =>
                {
                    c.UseDatabase(); // You can use FileSystem or Azure providers also.
                });
            }); 
        }
    
  • User Avatar
    0
    hinairusu created

    Found my solution to the context error post above.,

    you need to add in to moduleNameEntityFrameworkCoreModule.cs

    context.Services.AddAbpDbContext<FileManagementDbContext>(options =>
            {
                /* Remove "includeAllEntities: true" to create
                 * default repositories only for aggregate roots */
                options.AddDefaultRepositories(includeAllEntities: true);
            });
    
     Configure<AbpDbContextOptions>(options =>
            {
                options.Configure<FileManagementDbContext>(c =>
                {
                    c.UseSqlServer(b =>
                    {
                        b.MigrationsHistoryTable("__FileManagement_Migrations");
                    });
                });
            });
    

    and then create a connection string specifcially called FileManagement.

    I've pointed it at the table maintained by my existing DBContext, so hopefully that won't cause any issues down the line.

    I can however see the files uploaded by different users:

    But I cannot see the API request in the console as expected from the posts above. Could this be because I'm using Blazor Server rather than WASM?

    I've also noticed a bug, in which if you re-open the upload box after uploading you get a shadow entry still:

    Clicking the Browse button once clears the entry but doesn't open the browse structure.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I can however see the files uploaded by different users:

    This is by design.

    Could this be because I'm using Blazor Server rather than WASM?

    Yes, You can see the API request on mvc UI.

    I've also noticed a bug, in which if you re-open the upload box after uploading you get a shadow entry still:

    We will check this.

  • User Avatar
    0
    hinairusu created

    I have set up a new project on MVc, And I can see the API calls being sent. I think I have a rough ida of how to use these now. I've maaged to get the directory contents out as a DirectoryContentDto.

    Is there any way to display the file in question (Assume for the moment that it's a JPG) in the browser? so far everything I have tried just downloads the file, rather than displaying it in the browser.

    I'm looking to list the files in the directory as cards, in <img> tags.

  • User Avatar
    0
    hinairusu created

    Nevermind, I think I have figured it out. Thank you.

    It's frustrating I cant use the upload modal component out of the box, as I love the way it looks/feels, but at least now I have something to be working with.

    i have the directory section working, I have the file pull down and display.

    The upload however I still have issues with. the IFileDescriptorAppService doesn't have any methods for the PreUploadInfo, just a create with stream. I could swap it out for a direct rest call, but that seems counter to the ABP design, and if I did I don't understand the interaction between PreUploadInfo and Upload. Is the pre info required?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The source code of PreUploadInfo

Made with ❤️ on ABP v9.1.0-preview. Updated on November 01, 2024, 05:35