We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Stream error from Azure Blob Storage

Afternoon everyone,


I am in need of some support and I am pulling my hair out. I am trying to pull a PDF from Azure Blob to show in the PDF viewer. I am getting this error:
I have also added my code for reference:

I have tried async, non async, taking it out of the using statement and using dispose manually to no avail. It's bound to be something obvious, not sure what though...

I am using Blazor Server and .Net 7




public async Task Open()

{

using (MemoryStream memoryStream = new MemoryStream())

{

await CloudStorageAccount.Parse(ConfigurationService.GetValue("BlobConnectionString"))

.CreateCloudBlobClient()

.GetContainerReference("templates")

.GetBlockBlobReference("PDF Form.pdf")

.DownloadToStreamAsync(memoryStream);

Path = "data:application/pdf;base64," + Convert.ToBase64String(memoryStream.ToArray());

}

}




3 Replies 1 reply marked as answer

VV Visvesvar Venkatesan Syncfusion Team March 22, 2023 03:13 AM UTC

We are loading the document as base URL, loading as path and byte array and we were able to load.


Kindly find the code snippet and sample below.


Code Snippet:


@code {

    private string DocumentPath { get; set; } = https://www.syncfusion.com/downloads/support/directtrac/general/pd/a4-328485742.pdf;

    public SfPdfViewerServer viewer { get; set; }

   

    public void OnClickopen(MouseEventArgs args)

    {

        //Reads the contents of the file into a byte array, and then closes the file.

        byte[] byteArray = System.IO.File.ReadAllBytes("wwwroot/data/PDF_Succinctly.pdf");

        //Converts the byte array in to base64 string.

        string base64String = Convert.ToBase64String(byteArray);

        //PDF document will get loaded from the base64 string.

        viewer.Load("data:application/pdf;base64," + base64String, null);

    }

 

 

    public async Task Load()

    {

        string base64String = =";

        viewer.Load("data: application / pdf; base64," + base64String, null);

    }

}



Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/LO1B3B~11350954712.zip


Server sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ControllerPractice_load_using_URL-1061536387.zip


Steps to run the client and server:

Step 1) Run the server project and copy the hosting URL like "  https://localhost:44309/pdfviewer ".

Step 2) Paste the copied URL in the client URL and then run the client.


Try this sample and revert to us with the following details, if you have any concerns about this.


  • Modified sample or share the sample in which the issue is reproduced.
  • Code snippet
  • Replicate procedure
  • Conform the client and server-side packages are the latest one


This will be helpful for us to analyze further and provide the details.



RI Richard March 24, 2023 09:13 PM UTC

It turned out I was missing the max file size in the application CS..



Marked as answer

CK Chinnamunia Karthik Chinna Thambi Syncfusion Team March 27, 2023 08:16 AM UTC

Thanks for the update. If the reported issue has been resolved on your end, Please close this forum.


Loader.
Live Chat Icon For mobile
Up arrow icon