Activities of "elie.khadij"

Thank you, it worked.

Hey

I shared with you via email github repository of the test solution

regards

Ok i will share a test sample within 2 3 hours. Do you want it via email or discord or what are your steps

we are using Conventional Controllers, like the application Service. Maybe is it when you inject a scoped service and manipulate the stream from within? The blow method is part of a custom IBlobService that we created, which has a scoped life cycle. and I'm calling its method in my application service.

    // IBlobService
    public async Task<bool> SaveBlobAsync(IRemoteStreamContent file, CancellationToken cancellationToken = default)
   {
       using var memoryStream = new MemoryStream();
       await file.GetStream().CopyToAsync(memoryStream, cancellationToken); // this line throwing exception since it is touching stream position of HTTP request
       var fileContent = memoryStream.ToArray();
       await memoryStream.FlushAsync(cancellationToken);
       await blobContainer.SaveAsync(CleanFileName(file.FileName!), fileContent, true, cancellationToken);

       return true;
   }
   // end blobService
   
   public class MyApplicationService(IBlobService blobService) : IMyApplicationService
   {
       public async Task TestAsync(List<IRemoteStreamContent> files)
       {
           foreach(var file in files)
           {
               await blobService.SaveBlobAsync(file);
           }
       }
   }
   

Hello maliming Thank you for your reply, but the shared example is incompatible with my use case since you separated the streams into separate objects. Please try to put them in a List<IRemoteStreamContent>, and you will see that it won't work. If you try the example CreateMultipleFileInput here https://abp.io/docs/latest/framework/architecture/domain-driven-design/application-services#miscellaneous in the documentation, you will realize that the example shared does not work. I already shared an example with you when I opened the support ticket.

I encourage you to jump on a Teams call to elaborate more about this matter. Would Monday work for you?

Hello

sorry there was an override line on Microsoft log to Information, logs shared

thanks

Debug mode did not show the FormData anything required from my side?

regards Elie

Hello

this is the full log. If you want we can schedule a Teams meeting to share my findings more in details since we are on NDA.

regards Elie

Do you have any reply? The problem is from an Extension method you created that is resetting the stream position CopyToAsync(). It is overriding the virtual method of Stream! it is resetting the position to 0 while on Http requests Asp net core itself manages the streams

Hello, we are using IRemoteStreamContent to upload images in our solution. let's say we have a DTO called A identified like so:

public record A {
    public string Name {get; init;}
    public B Bs {get; init;}
    public List <IRemoteStreamContent> Images {get; init} = [];
}

Let's say we have an Application Service named TestApplicationService. In this service, I'm calling a Custom Blob Service that uploads Azure blob images.

public class TestAppService : AppService {
    public Task<bool> CreateRecordA(A dto)
    {
        foreach(var image in dto.Images)
        {
         await blobService.SaveBlobAsync(image);
        }
        
        return true;
    }
}

as for the Custom blob Service I will expose the method as follows:

    public async Task<bool> SaveBlobAsync(IRemoteStreamContent file, CancellationToken cancellationToken = default)
    {
        using var memoryStream = new MemoryStream();
        await file.GetStream().CopyToAsync(memoryStream, cancellationToken);
        var fileContent = memoryStream.ToArray();
        await memoryStream.FlushAsync(cancellationToken);
        await blobContainer.SaveAsync(CleanFileName(file.FileName!), fileContent, true, cancellationToken);

        return true;
    }

In our host module we added this line in conventional controllers:

        Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options.ConventionalControllers.FormBodyBindingIgnoredTypes.Add(typeof(A));
            options.ConventionalControllers.Create(typeof(TestApplicationModule).Assembly);
        });

The problem is that whenever I have more than 1 image in my dto we are facing an exception of HTTP stream positioning changed unexpectedly, noting that we followed step by step https://abp.io/docs/latest/framework/architecture/domain-driven-design/application-services#miscellaneous

  • Exception message and full stack trace:
System.InvalidOperationException: The inner stream position has changed unexpectedly.
   at Microsoft.AspNetCore.Http.ReferenceReadStream.VerifyPosition()
   at Microsoft.AspNetCore.Http.ReferenceReadStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at System.IO.Stream.&lt;CopyToAsync&gt;g__Core|27_0(Stream source, Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
   at Totssy_Backend.BuildingBlocks.Services.Blob.BlobService.SaveBlobAsync(IRemoteStreamContent file, CancellationToken cancellationToken) in C:\Repos\Lykos\Totssy-Backend\src\Totssy_Backend.BuildingBlocks\Services\Blob\BlobService.cs:line 80
   at StockManager.Services.Catalog.CatalogsAppService.PostProductAsync(CreateProductDto productDto)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
  • Steps to reproduce the issue:
Showing 1 to 10 of 21 entries
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.1.0-preview. Updated on December 17, 2025, 07:08
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.