AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Streaming sample works even for other document types (like PDF) with a small change

Open maraf opened this issue 1 year ago • 7 comments

Description

I recently had a conversion with blazor customer who has a need to preview other document types (like PDF). The documentation sample for streaming images works for other document types as well with two changes

  • (expectedly) replace img tag with iframe or embed
  • (this is hidden gem) provide content type when creating the Blob in javascript

I have put it together and created a sample https://github.com/maraf/blazor-file-stream.

I'm opening this issue as a consideration for mentioning pain-points in more general usage or providing the more general sample

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/images?view=aspnetcore-8.0#stream-image-data

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/images.md

Document ID

66bb1712-60ac-77a6-10d2-f2d795126783

Article author

@guardrex

maraf avatar Mar 01 '24 13:03 maraf

This time I have used the button in the documentation page 🎉 (thanks guardrex!)

maraf avatar Mar 01 '24 13:03 maraf

Thanks @maraf ... Let's ask @mkArtakMSFT to triage.

guardrex avatar Mar 01 '24 13:03 guardrex

Thanks for the suggestion, @maraf . I am not a fan of iframe-s in general. Also, I like to keep our samples focused only for the scenario they target, as otherwise it expands the surface area for questions. Because "I am not a fan of iframe-s" is not a technical justification, I'm willing to hear what @javiercn has to say about this.

mkArtakMSFT avatar Mar 14 '24 17:03 mkArtakMSFT

Just a note on iframe, embed or object are alternatives

maraf avatar Mar 14 '24 20:03 maraf

I think we can add a section on the docs. If for example creating a blob url with the right content type works for displaying a PDF inside an iframe, that's a valid scenario.

javiercn avatar Apr 02 '24 16:04 javiercn

I'll use that example exactly (PDF in an iframe).

I'm working down all of the backlogged issues now that have been on hold while .NET 8 issues were the priority. I'll get to this in due course, probably within a month ... or three! 🙈😆

guardrex avatar Apr 02 '24 16:04 guardrex

No rush, it's just a trifle

maraf avatar Apr 02 '24 18:04 maraf