Open Closed

Upload -> RemoteStreamContent no contentlength in generated clientproxy #3913


User avatar
0
rick@i-pulse.nl created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v5.3.3
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

We use the upload functionality with MVC and we generated clientproxy due to a bug in ABP. When we upload a file, the contentlength is 0 when we reach the generated clientproxy.

Contorller

Upload method in generated proxy

<br> In the AppService the contentlength is also 0

What is going wrong with this upload? This worked in an older version of ABP without the generated proxy.

Thanks.

<br>


1 Answer(s)
  • User Avatar
    0
    berkansasmaz created
    Support Team .NET Developer

    There is a breaking change regarding using IRemoteContentStream in version 5.0.0. It seems to me that the object is probably disposed of while you call Upload

    ref: https://github.com/abpframework/abp/pull/9180

    But it would be great if you could test this to speak beyond the assumptions. For this, you can pass false to disposeStream parameter while creating an instance of RemoteStreamContent.

    new RemoteStreamContent(...., disposeStream: false)

    If it is as I said, I believe you can solve the problem similar to the code below:

                    await using var memoryStream = new MemoryStream();
                    if (Organization.ProfilePictureFile != null && Organization.ProfilePictureFile.Length > 0)
                    {
                        await Organization.ProfilePictureFile.CopyToAsync(memoryStream);
                        memoryStream.Position = 0;
                        
                        createOrganizationDto.ProfilePictureStreamContent = new RemoteStreamContent(memoryStream, fileName: Organization.ProfilePictureFile.FileName, contentType: Organization.ProfilePictureFile.ContentType);
                    }
    
                    var organization = await _organizationAppService.CreateAsync(createOrganizationDto);
                    await memoryStream.DisposeAsync();
    

    ref: https://github.com/abpframework/eventhub/blob/f95fda41dbd821c905ed6c675e946a86fb91a6fa/src/EventHub.Web/Pages/Organizations/New.cshtml.cs#L42-L52

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