Bashir Magomedov
Bashir Magomedov

Reputation: 2881

.net core web api File randomly loads only part of the response

I am loading an image from S3 bucket as byte[] and send it as a response from my asp.net core 3.1 web API controller method.

Here is my code:

    public async Task<IActionResult> GetImage(string documentId, int pageId)
    {
        var imageArray = await _documentService.GetImage(documentId, pageId);
        return File(imageArray, "image/png");
    }

It works to an extend. The Response is delivered to the client:

enter image description here

But the image itself is never fully loaded:

sometimes it loads just a little bit:

enter image description here

sometimes a bit more:

enter image description here

But never the full image. Looks like it interrupts for whatever reason and just sends whatever got into the initial buffer.

Upvotes: 0

Views: 152

Answers (1)

Bashir Magomedov
Bashir Magomedov

Reputation: 2881

Thanks to @Athanasios - the issue is not related to the File response. I wasn't reading the S3 stream properly. The error has gone after fixing it.

Upvotes: 0

Related Questions