Starts in:
2 DAYS
5 HRS
7 MIN
20 SEC
Starts in:
2 D
5 H
7 M
20 S
Open Closed

Problem uploading a file using MultipartReader #2267


User avatar
0
Sturla created

I´m trying to upload a big file using multipart request but using this framework I´m getting the following error

"Unexpected end of Stream, the content may have already been read by another component."

There is like something in Abp is "messing with" the communication and I can´t find out what.

I asked this question in details at GitHub but like to get some priority on it by posting it also here. Hope hearing from you soon.

  • ABP Framework version: v4.4 (also in a 4.4.4 project)
  • UI type: Blazor
  • DB provider: EF Core
  • Identity Server Separated: yes

7 Answer(s)
  • User Avatar
    0
    Sturla created

    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.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    https://github.com/abpframework/abp/issues/10916#issuecomment-993261785

  • User Avatar
    0
    Sturla created

    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;
    }
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The IRemoteStreamContent is similar with IFormFile.

    Please follow the recommended from asp net core

    https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-6.0#additional-resources

  • User Avatar
    0
    Sturla created

    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?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Isn't that something you should offer in the framework, large file upload?

    We should follow the Microsoft recommendation.

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

    It only has simple http upload.

  • User Avatar
    0
    Sturla created

    Yes I have decided to go with Syncfusion (or at least try to get it to work) but am having issues with that and created this ticket here for that. So I'll close this one and hope you can help me with the other one (where IRemoteStreamContent is not solving my issue).

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