Activities of "Sturla"

I have just updated my demo repo with the code for you to try out. Just F5 and upload file with Browse

Here is the Blazor code and here is the API that gets hit but is always empty (except with SwaggerUI).

Sorry that doesn't work. I have tried every mutation of that. I just don't understand that it works with SwaggerUI but not Blazor if there is no setting or something I need to configure...

After trying things out and searching the internet for answers I found out that Blazor WASM 5.0 does only support ~<2GB upload it seems. I asked this question here that will hopefully move me in the right direction.

But if all fails I will try out this Syncfusion large-file-chunk-upload. Isn't that something you should offer in the framework, large file upload?

How does the File Management Module deal with such large files?

Thank you for your answer Maliming, I haven't tried this with huge files yet (will today) but I was wondering what approach you would recommend taking to upload to blob from the service. Stop in a temp file or directly from stream?

public async Task<string> UploadBigFileAsync(IRemoteStreamContent streamContent)
{
    var filePath = Path.GetTempFileName();

    // use local temp file
    using (var fs = new FileStream(filePath, FileMode.Create))
    {
        await streamContent.GetStream().CopyToAsync(fs);
        await fs.FlushAsync();
    }

    var blobName = $"Uploaded-{streamContent.FileName}";

    // then read it to blob
    var bytes = await File.ReadAllBytesAsync(filePath);
    await blobContainer.SaveAsync(blobName, bytes, overrideExisting: true);

    return blobName;
    
    //delete file finaly()
}

Or just stream it directly

public async Task<string> UploadBigFileAsync(IRemoteStreamContent streamContent)
{
    var blobName = $"Uploaded-{streamContent.FileName}";
    
    await blobContainer.SaveAsync(blobName, streamContent.GetStream(), overrideExisting: true);

    return blobName;
}

I updated the code in my github question to have both a none-working abp version and a working classic Blazor/api that works.

Hopefully this is just some configuration problem but I haven't found it.

Answer

Suite can't be used because it doesn't find xPermissions.cs or xPermissionDefinitionProvider.cs if they have been (like I had to do) moved to another project/place.

So at the moment I just can't use Suite at all to add properties/entities and I have to do it manually.

Bingo! That seems to have solved the problem! Thanks for your patiance with me ;-)

Here it is but the "create a tenant UI" is missing (not sure how the open source version works) so I couldn´t try that out.

I added some information to the Readme file but I hope this is all self explanatory what I´m trying to do.

Yes that is what I gathered

If I change the tenant to nul l I get the roles

[UnitOfWork]
public async virtual Task HandleEventAsync(EntityCreatedEto<UserEto> eventData)
{
    using (currentTenant.Change(null)) 
    {  
    var roleNotFound = await identityRoleRepository         
        .FindByNormalizedNameAsync(lookupNormalizer
        .NormalizeName(RoleConstants.TenantClientRole));
    }
}

BUT then I can´t add the role becuse the created user is not found

// this then throws
var userJustCreated = await identityUserManager.GetByIdAsync(eventData.Entity.Id/TenantId);
   
// this
'There is no such an entity. Entity type: Volo.Abp.Identity.IdentityUser, id: 7f7acfe7-4abe-2a43-f31f-39fe74a2a237'

What secret sauce/steps do I need?

One small help before I close this issue, because I really want to use role with permissions.

So why can't the role not be found when using the IDistributedEventHandler but is when seeding data?

[UnitOfWork]
public async virtual Task HandleEventAsync(EntityCreatedEto<UserEto> eventData)
{
    using (currentTenant.Change(eventData.Entity.TenantId)) 
    {   
        //This never returns the roles created when I seed. I have tried to skip the using etc.
        var role = await   identityRoleRepository
            .FindByNormalizedNameAsync(lookupNormalizer.NormalizeName(RoleConstants.TenantClientRole));
    
    if (role is null)
    {
        var newRole = new IdentityRole(guidGenerator.Create(),
            RoleConstants.TenantClientRole) { IsPublic = true, IsStatic = true };
        await identityRoleRepository.InsertAsync(newRole, true); 
    }
    
    //this will just return null
    var roleNotFound = await identityRoleRepository
        .FindByNormalizedNameAsync(lookupNormalizer.NormalizeName(RoleConstants.TenantClientRole));
    
    //and then I can't AddToRoleAsync because the role is not found!
    var userJustCreated = await identityUserManager.GetByIdAsync(eventData.Entity.Id);
    
    //this throws "Role TENANTCLIENTROLE not found"
    await identityUserManager.AddToRoleAsync(userJustCreated, RoleConstants.TenantClientRole); 
    }
}

And if I change to "null" tenant with using (currentTenant.Change(null)) I get the roles but var userJustCreated = await identityUserManager.GetByIdAsync(eventData.Entity.Id); throws "There is no such an entity".


For completeness sake I´m able to run and seed the role with the DbMigrator with basically the same code

public async Task SeedAsync(DataSeedContext context)
{
    var role = await identityRoleRepository
        .FindByNormalizedNameAsync(lookupNormalizer.NormalizeName(RoleConstants.TenantClientRole));
    
    if (role is not null)
    {
        return;
    }

    // Create the role and insert it
    var newRole = new IdentityRole(guidGenerator.Create(), 
        RoleConstants.TenantClientRole) { IsPublic = true, IsStatic = true };
    await identityRoleRepository.InsertAsync(newRole,true); 
    
    //returns the role
    var roleFound = await identityRoleRepository
        .FindByNormalizedNameAsync(lookupNormalizer.NormalizeName(RoleConstants.TenantClientRole));
}

Hopefully I can just close this off after this question. Thanks so much for your asstance!

Showing 81 to 90 of 113 entries
Made with ❤️ on ABP v9.2.0-preview. Updated on January 14, 2025, 14:54