Open Closed

[ExtraProperties - File Management] FMFileDescriptor add Extra Properties, the value can not save #5741


User avatar
0
thanhlg created

Check the docs before asking a question: https://docs.abp.io/en/abp/latest/Module-Entity-Extensions , https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities , https://docs.abp.io/en/abp/latest/Entities, modules/file management | Documentation Center | ABP.IO

  • ABP Framework version: 7.3.2
  • TemplateType: Module Template (ABP Suite)
  • UI Type: Blazor WASM
  • Database System: EF Core (PostgreSQL)

I'm using File Management Module to get Upload methods in another page and I am also using ExtraProperties to add DocId and Url properties to FMFileDescriptor table. I tried for IdentityUser and it works fine, but File Management doesn't.

How can I use Extended Entities for File Management Module and refer to a specific property and it's value in the .ExtraProperties collection and place it in my UI individually?

Thanks


17 Answer(s)
  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi giathanh2512,

    I have checked your code I think you are not passing that value from File Management Module UI, you need to remove that properties like shown in screenshot.

    please try with this code

    property.Api.OnCreate.IsAvailable = false;
    property.Api.OnUpdate.IsAvailable = false;
    

    please do let me know if this helps you.

    Thank You, Anjali

  • User Avatar
    0
    thanhlg created

    Hi Anjali,

    Thank you for the information. It worked! Could you please tell me how to get and set the values for ExtraProperties in the FMFileDescriptor table of the File Management Module? I want to use FMFileDescriptor to store additional properties like DocId and Url, which are intended for managing the saving and retrieval of multiple images for a page.

    Here is the code I'm using to upload files and save the images:

    private CreateFileInputWithStream EditingImageFile { get; set; }
    
    private async Task OnFileSelection(InputFileChangeEventArgs e)
    {
        var files = e.GetMultipleFiles();
        foreach (var file in files)
        {
            var resizedFile = await file.RequestImageFileAsync(file.ContentType, 500, 500);
    
            var buffers = new byte[resizedFile.Size];
            string imageType = resizedFile.ContentType;
            using (var stream = resizedFile.OpenReadStream())
            {
                await stream.ReadAsync(buffers);
            }
    
            EditingImageFile = new CreateFileInputWithStream
            {
                Name = resizedFile.Name,
                File = new RemoteStreamContent(
                            stream: new MemoryStream(buffers),
                            fileName: resizedFile.Name,
                            contentType: imageType,
                            disposeStream: true
                        )
            };
    
            var image = await FileDescriptorsAppService.CreateAsync(directoryId, EditingImageFile);
            await GetFileContent();
    
            await OnImageUploaded.InvokeAsync(image.Id);
            StateHasChanged();
        }
    }
    

    ABP Framework version: v7.3.2

    TemplateType: Module Template (ABP Suite)

    UI Type: Blazor WASM

    Database System: EF Core (PostgreSQL)

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi

    please see this link in this way you can set and get values of extraproperty

    https://docs.abp.io/en/abp/latest/Object-Extensions#some-best-practices

    create extension class (in DomainModule) for that entity and then call that extension methods from you application layer or domain layer.

  • User Avatar
    0
    thanhlg created

    How can I use getting and setting ExtraProperties in a Blazor page? Can you provide an example?

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi giathanh2512,

    You can setproperty to the CreateFileInputWithStream class from your upload fuction in razor page. I am adding a code screenshot for your reference.

    regards, Anjali

  • User Avatar
    0
    thanhlg created

    Hi Anjali, I have tried multiple approaches, including the one you suggested, but it still doesn't work.

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Support Team Member

    Hi

    if you are passing these values from UI then you can remove these two line which we added.

    if you are not passing then these are required.

  • User Avatar
    0
    thanhlg created

    I have deleted it.

    When I use the "Url", it shows a mandatory error message.

    When I try to fix it to the "url", the update method doesn't work at all.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi giathanh2512

    Can you share the HTTP request info for this request? the full headers.

    You can also share a simple project to me

    liming.ma@volosoft.com

    Thanks.

  • User Avatar
    0
    thanhlg created

    Hi maliming,

    I have sent you an email, please check and assist me. Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok, I will check it asap.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you create a new template project?

    The project you shared uses the DevExpress and database migrations are incorrect.

    Thanks.

  • User Avatar
    0
    thanhlg created

    hi

    Can you create a new template project?

    The project you shared uses the DevExpress and database migrations are incorrect.

    Thanks.

    I have updated the new version for the source link. I have also tested running the migration again, and it is working fine. Please review it again. Thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks. I am checking right now.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I sent the project

    thanhlg@xxxx.com.vn

  • User Avatar
    0
    thanhlg created

    I sent the project

    thanhlg@xxxx.com.vn

    It worked. Thank you very much.🌻

  • User Avatar
    0
    jfistelmann created

    Hey,

    it seems like the issue is resolved. I close this question now.

    feel free to reopen if i am wrong :)

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